install python dockerfile code example

Example 1: install python3 in dockerfile

RUN apk upgrade --update && apk add --no-cache python3 python3-dev

Example 2: install python in dockerfile

RUN apt-get update
RUN apt-get install python

Example 3: install python 3.6 dockerfile

RUN apt-get install -y build-essential python3.6 python3-pip python3.6-venv

Example 4: how to run python file from cmd in dockerfile

FROM python:3

ADD my_script.py /

RUN pip install pystrich

CMD [ "python", "./my_script.py" ]

Example 5: dockerfile to run python script

docker run -it --rm --name my-first-python-script -v "$PWD":/usr/src/widget_app python:3 python my_script.py