Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Guidelines for Creating Dockerfiles

Scott Collier edited this page Mar 25, 2014 · 17 revisions
README

We would like to provide a consistent experience for consumers of Dockerfiles. We are providing some guidelines here that will help.

  • Each Dockerfile example should include a README that contains the following.

    • The version of Docker that it was created and tested on.

      • For example: Tested on Docker 0.9.0

    • Instructions on how to build the Docker image.

      • For example: docker build -rm -t example/example

    • Instructions on how to run the Docker image

      • If the Dockerfile has to do with any container that needs to store persistent data outside the container, such as a database, the example needs to show how to do this.

      • If the Dockerfile has an application that exposes ports, show how to perform a port to port mapping ( -p 80:80) and a random port mapping ( -p 80 ).

    • How to test it and confirm functionality

      • If the container is running MongoDB, show how to connect to it with the MongoDB client (mongo --port 49127). If the container is running a web server, show how to access the web site (curl http://localhost:49127), etc…​

  • Don’t include executable scripts. Just provide the scripts and mark them executable in the Dockerfile. For example:

ADD ./script.sh /usr/bin/
RUN chmod -v +x /usr/bin/script.sh
  • If creating a container for a language, like Python, please include the version of that language.

  • If using yum as part of the build process, run a clean after to reduce the amount of space taken.

RUN yum -y update; yum -y install pkg1 pkg2; yum clean all
Clone this wiki locally