user1751825 user1751825 - 2 months ago 16
Perl Question

How should I handle Perl module updates when maintaining docker images?

I'm working on building a docker image to be able to run all of our Perl applications. The applications require hundreds of CPAN modules to be installed. The full build of the docker image takes about an hour to complete.

After doing the initial image, I'm not sure how best to handle ongoing updates.

  1. We could keep a single Dockerfile in git, and then modify this as required, and push new builds up to dockerhub. However if the person doing the build doesn't have all of the intermediate images, then adding a single CPAN module could be an extremely tedious process, and it might take an hour before they even know if the new module installs correctly. Also it would be downloading every CPAN module again, which seems a bit risky, as there might be a breaking change in the new module.

  2. Alternatively, the person doing the build could pull the latest docker-hub image, and then install the cpan module interactively, commit the build and push the new image to dockerhub. However then we only have our dockerhub images, but not master Dockerfile.

  3. Or another option would be to create a Dockerfile for each new build, which references the previous dockerhub image. This seems overly complicated though.

Option 1) seems wrong. I'm fairly sure we don't want to be rebuilding the entire image from the base OS just to install one additional module. However being dependent on images without Dockerfiles seems risky as well.


You could use the standard module installer for your underlying OS on your docker image.

For example, if its RedHat then use yum and only use CPAN when they are not available

FROM centos:centos7
  RUN  yum -y install cpanm gcc perl perl-App-cpanminus perl-Config-Tiny &&  yum clean all
  RUN cpanm install Some::Module; rm -fr root/.cpanm; exit 0

taken from here and modified

I would try to have a base image which the actual applications use

I would also avoid doing things interactively (e.g. script a dockerfile) as you want to be able to repeat the build when upstream dependencies change, which docker hub does for you.

EDIT You can convert perl modules into your own packages using dh-make-perl

You can load these into your own Ubuntu repo using reprepro or a paid solution of Artifactory

These can then be installed using apt-get when you use your repo as a source from within a dockerfile.

When I have tried a similar thing before There are a few problems

  • Your apps don't work with the latest version of modules
  • There are far more dependencies than you expected
  • Some modules wont package

Benefits are

  • You keep the build tools (gcc, etc) off the app servers
  • You know much more about your dependencies