cha_pppo blog

i have an unbeknown dictionary. everything is up to me.

PythonをDocker経由で実行する

Environment

  • Python3
  • Docker Desktop (for Mac): 2.0.0.3
  • Docker engine: 18.09.2

Dockerfile

FROM python:3

WORKDIR /path/to/pwd

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
#!/usr/bin/env python
# -*- coding: utf-8 -*-

print('xxx')

requirements.txtの中は適宜.

Docker run

作成したスクリプト (正確にはDockerfileがあるcurrent directory) をcontainerにmountして実行する.

% docker run -it --rm --name python_test -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3 python python_test.py
heee