Container: Developing an Application - Docker Quick Reference Guide


Additional vendor documentation: 
Docker Vendor Documentation
OpenShift Project Administration Documentation

Efficient Dockerfiles

The Docker build process caches where possible to speed up builds. Order actions in the Dockerfile so that commands that usually produce the same result, or that are unlikely to change, come early. E.g. Put utility installation / update code before compiling source under active development.

Build Fails On Status Code That Can Be Ignored

A RUN command in a Dockerfile may sometimes return non 0 exit status even though the issue isn't important. To ignore that ensure that the command returns 0. For example:

RUN find / -name -ls; exit 0;

Docker Runs Out of Space

If Docker is giving out of space errors, use: 

docker system df
docker system info

to verify the problem and use:

docker system prune

to free up lots of space.

Mounting Volumes Locally

While developing applications to run on OpenShift it may be useful to be able to run the application locally without OpenShift.  One issue is that OpenShift provides some environment conveniences that Docker does not.  In particular it will take care of mounting external storage, such as file systems and secrets, at designated locations in the container.  See below for an example of how to do that directly with Docker.

This is an example of mounting the contents of 'temp/tl-outage/httpd-conf/'  inside your running container at '/tmp/apache-conf'.

docker run -it -p 443:443 -v /temp/tl-outage/httpd-conf:/tmp/apache-conf tl-outage

This can be very useful for running an application container locally with Docker without needing to change the container for running on OpenShift.

Docker Compose

OpenShift can leverage docker compose applications. The kubernetes community maintains a tool called kompose that converts compose applications into Kubernetes/OpenShift format, and can alternatively bring the apps up or down. More documentation on kompose is available here. The matrix of support docker compose syntax is available here.

Last Updated: 
Monday, September 10, 2018