Differences between revisions 2 and 3
Revision 2 as of 2019-03-25 09:41:07
Size: 556
Editor: PieterSmit
Comment:
Revision 3 as of 2019-03-25 11:09:45
Size: 694
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
   1. create dir myapp, in it add src/myapp.py and requirements.txt
Line 18: Line 19:
CMD ["gunicorn", "-w 4", "main:app"] CMD ["python" . "myapp.py"]
Line 20: 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 
  • Python docker build file
    1. 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

docker/Python (last edited 2020-04-06 19:31:13 by PieterSmit)