google/python-runtime is a docker base image for easily running Python application.
It is based on google/python base image.
-
Create a Dockerfile in your python application directory with the following content:
FROM google/python-runtime -
Run the following command in your application directory:
docker build -t my/app .
- Your application sources are copied into the
/appdirectory. - A virtualenv with your dependencies is created under the
/envdirectory.
The image assumes that your application:
- has a
requirements.txtfile to specify its dependencies - listens on port
8080 - either has a
main.pyscript as entrypoint or definesENTRYPOINT ["/env/bin/python", "/app/some_other_file.py"]in itsDockerfile
When building your application docker image, dependencies of your application are automatically fetched in a virtualenv using pip install.