RTFM: docker-pkg edition
In today’s edition of RTFM…
I’ve been working on building Docker images to use with MediaWiki’s docker-compose development environment. We don’t use standard Dockerfiles and
docker build commands, instead we use an in-house tool called
docker-pkg, which uses Jinja for additional templating.
So, while working on these images, for months now I’ve been running commands like
docker-pkg -c dockerfiles/config.yaml build --no-pull --select '*stretch-php72-fpm-apache2*' dockerfiles and then doing something else while the image builds, because unlike
docker build the layers of the image are not cached.
Yesterday I wanted to tighten the feedback loop while working on phab:T223643 to create an EventLogging image, so I started looking at how I could use the Docker build cache. While not mentioned on the documentation page, sure enough, hiding in plain text:
docker-pkg build --help usage: docker-pkg build [-h] [--nightly | --snapshot] [--use-cache] [--no-pull] [--select GLOB] optional arguments: -h, --help show this help message and exit options for docker build: --use-cache Do use Docker cache when building the images --no-pull Do not attempt to pull a newer version of the images --select GLOB A glob pattern for the images to build, must match name:tag
And so, with
--use-cache adjusting the
ENTRYPOINT command for that EventLogging image took a few seconds instead of minutes.
While kind of embarrassing to admit I missed this option, some lessons for me are:
- tools which wrap around other tools should probably use the same defaults (e.g.
docker buildcaches by default and has a
docker-pkgshould probably have a
--no-cacheoption rather than the inverse
- when unexpected option defaults are needed they should be called out in the documentation
- and of course: RTFM!