36

Using docker, you can create images based on other images very nicely. For instance, you can make an image Java-jdk7 (based on the latest Ubuntu LTS), and based on that create images elastic-search and tomcat7 (both of which need java).

So, if I don't tag my images, I end up with the following (extract of docker images):

╔══════════════════════╦════════╦══════════════╗
║      REPOSITORY      ║  TAG   ║      ID      ║
╠══════════════════════╬════════╬══════════════╣
║ ubuntu               ║ 12.04  ║ 8dbd9e392a96 ║
║ quintenk/jdk7-oracle ║ latest ║ 8928245086f4 ║
║ quintenk/tomcat7     ║ latest ║ 995cdb2cbfa8 ║
║ quintenk/elastics    ║ latest ║ 123abc456ef2 ║
╚══════════════════════╩════════╩══════════════╝

Now for the question. How do/should I maintain this dependency? How do I perform maintainance one 1 image and the dependent images as well?

  1. If I update my jdk image (apt-get upgrade for instance), I assume I do not corrupt the dependent images? However, I also assume that the dependency tree is not as you would expect any longer. [UPDATE: I've reproduced this, so see my own answer below]
  2. If 1 is correct, is there some way that I can have the dependent images flag themselves as outdated, and (hopefully) have them rebuild themselves?

Or is the way to go to tag the containers with a version number, and manually rebuild and redistribute all dependencies with increased version number tags? That would mean the Dockerfiles would need to be altered for an update.

UPDATE: I found the following image on the docker site in their presentation. However, I'm not quite sure on the steps of how to do this (especially with dependencies on other images as I described).

Update flow for docker containers

2
  • Is docs.docker.com/docker-hub/builds/#repository-links the solution you want? It re-build all depending images if change being made at their base images. Commented Feb 27, 2015 at 6:39
  • @WeiChing indeed - that would be the new answer. Of course - this is a bad thing without automated testing Commented Feb 27, 2015 at 10:06

4 Answers 4

9

This is a great use case. Please submit an enhancement request on the Docker issues page.

A simple way for now is to maintain the Dockerfiles and update from there, rebuilding the images when you want to make a deliberate change.

Sign up to request clarification or add additional context in comments.

2 Comments

Just did. I don't see it yet, so I guess it will be reviewed before it gets published.
This is the enhancement request: github.com/dotcloud/docker/issues/1379 which was closed in favour of this one: github.com/dotcloud/docker/issues/2936
7

In answer to

If I update my jdk image (apt-get upgrade for instance), I assume I do not corrupt the dependent images? However, I also assume that the dependency tree is not as you would expect any longer.

I've verified this by updating a dependent image, and checking out the dependencies. What you get is indeed a valid state, but the dependent image is not based on the image you'd naively expect any longer:

docker dependency tree

Comments

0

I feel using multi-stage builds can also be helpful in avoiding such pitfalls. It will help you keep single dockerfile per application.

Comments

0

I recently implemented a simple program, CLade, for exactly the same needs as yours.

Take a look around: https://github.com/lesomnus/clade

Your example can be expressed in CLade's port.yaml like this:

name: registry.hub.docker.com/quintenk/tomcat7
images:
  - tags: ['latest']
    from: registry.hub.docker.com/quintenk/jdk7-oracle:latest

However, you need to run the clade build command manually, but you can list outdated images via the clade outdate command. I used these commands to automate the build in CI. If interested, see https://github.com/lesomnus/clade/blob/main/.github/workflows/clade-outdated.yaml.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.