Public | Automated Build

Last pushed: 3 years ago
Short Description
Short description is empty for this repo.
Full Description

Python runtime Dockerfile

This repository contains Dockerfile of Python runtime for my automated build published to the public Docker Hub Registry.

This image is a base image that makes it easy to dockerize standard Python application.

It can automatically bundle a Python application with its dependencies and set the default command with no additional Dockerfile instructions.

This project is based on Docker's own automated build, which itself heavily borrowed code from Google's google/python-runtime Docker image.

Base Docker Image


  1. Install Docker.

  2. Download automated build from public Docker Hub Registry: docker pull clementmangin/python-runtime

    (alternatively, you can build an image from Dockerfile: docker build -t="clementmangin/python-runtime"


This image assumes that your application:

  • has a apt-requirements.txt file to specify its system dependencies.
  • has a requirements.txt file to specify its python dependencies.

When building your application docker image, ONBUILD triggers:

  1. Install the dependencies listed in apt-requirements.txt using apt-get install and leverage docker caching appropriately.
  2. Fetch the dependencies listed in requirements.txt into the virtualenv using pip install and leverage docker caching appropriately.
  3. Copy the application sources under the /app directory in the container
  • Step 1: Create a Dockerfile in your Python application directory with the following content:
    FROM clementmangin/python-runtime
  • Step 2: Expose any port your app listens to and/or give the default command:
    EXPOSE ["80"]

    # ENTRYPOINT is set to ["python"] in the base image
    CMD [""]
  • Step 3: Build your container image by running the following command in your application directory:
    docker build -t="app" .
  • Step 4: Run application by mapping port 80:
    APP=$(docker run -d -p 80 app)
    PORT=$(docker port $APP 80 | awk -F: '{print $2}')
    echo "Open http://localhost:$PORT/"
Docker Pull Command