369
Comment:
|
703
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
* Run python script in docker envelope {{{ $ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3 python script.py }}} |
|
Line 3: | Line 6: |
* Python docker build file 1. create dir myapp, in it add src/myapp.py and requirements.txt |
|
Line 14: | Line 19: |
CMD ["gunicorn", "-w 4", "main:app"] | CMD ["python" . "myapp.py"] |
Line 16: | Line 21: |
* Build with $ docker build -t myapp . * Run with $ docker run --rm myapp |
Docker Python build file
Run python script in docker envelope
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3 python script.py
- Python docker build file
- create dir myapp, in it add src/myapp.py and requirements.txt
FROM python:3.7-alpine as base FROM base as builder RUN mkdir /install WORKDIR /install COPY requirements.txt /requirements.txt RUN pip install --install-option="--prefix=/install" -r /requirements.txt FROM base COPY --from=builder /install /usr/local COPY src /app WORKDIR /app CMD ["python" . "myapp.py"]
- Build with $ docker build -t myapp .
- Run with $ docker run --rm myapp