dockarchive

I’ve spent the past two days working on a way to improve Docker image generation, by using the C preprocessor to allow me to include Dockerfiles in other Dockerfiles. Part of this was to eliminate redundant typing, with the bonus that I’ve been able to code best-practice directly into the includeable Dockerfiles.

I’ve checked all this into this github repository — https://github.com/nuket/dockarchive — to keep track of things.

For example, let’s say you want to run an SSH server (sshd) in a Docker container. One of the ways to do this is to use supervisord, to start and to keep it running. So there’s an implicit dependency, which can be captured in the following way:

Dockerfile.supervisord

Dockerfile.ssh

Dockerfile.supervisord.run

The sshd installation can pull in its dependency and add a configuration to be automatically started by supervisord. Docker images can then be built up in an orderly way and complexity cut into smaller pieces, as each piece only needs to worry about its own particular configuration. In this way, the pieces can be combined into full images.

As an example, the source for one of my Docker images is very simple now, since the dependency tree is taken care of:

buildbot-master/Dockerfile.in

Then you just use the C preprocessor to create the actual Dockerfile and then build that:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.