How to write a Dockerfile for a custom python project?
Question: I'm pretty new to Docker, and I need to create the container to run Docker
container as an Apache Mesos task.

The problem is that I can't find any relevant examples. They all are centered
around Web development, which is not my case.

I have a pure Python project with large number of dependencies ( like Berkeley
Caffe or OpenCV ). How to write a Docker file to properly enroll all
dependecies ( and how to find them out?)


Answer: The docker hub registry contains a number of official language images, which
you can use as your base image.

  * <https://hub.docker.com/_/python/>

The instructions tell you how you can build your python project, including the
importation of dependencies.

    
    
    ├── Dockerfile                <-- Docker build file
    ├── requirements.txt          <-- List of pip dependencies
    └── your-daemon-or-script.py  <-- Python script to run
    

Image supports both Python 2 and 3, you specify this in the Dockerfile:

    
    
    FROM python:3-onbuild
    CMD [ "python", "./your-daemon-or-script.py" ]
    

The base image uses special [ONBUILD
instructions](https://docs.docker.com/engine/reference/builder/#onbuild) to
all the hard work for you.

