-
Notifications
You must be signed in to change notification settings - Fork 239
Guidelines for Creating Dockerfiles
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 1.8.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 by the cache.
RUN yum -y update; yum -y install pkg1 pkg2; yum clean all
or
RUN dnf -y update; dnf -y install pkg1 pkg2; dnf clean all
Fedora-Dockerfiles have a number of branches. It is done to ensure that we do not break the fedora-dockerfiles package in different releases of Fedora. Branch follows the release version. For example, f22 branch is suitable for Fedora 22 release, f21 is for Fedora 21 and so on. We will use master branch for rawhide.
Accordingly, the way we accept and merge the pull requests will change. If a contributor has written a Dockerfile for Fedora 22 then they should give a pull request for f22 branch. This can be done by choosing appropriate branch from github’s web user interface while creating a pull request. We would test the Dockerfile against the right Fedora release and merge the request or comment the suggestions to fix appropriately.