Docker Community Forums

Share and learn in the Docker community.

Will new Container Image Retention Policy break Dockerfile's?

As much as I understand that Docker hub must be cleaning up, I fear that the new image rentention policy may break many Docker recipe’s

Say I have a docker file

FROM php:4.2.3-apache

Now that may work fine, but the image will be cached on my computer, I never pull. If I at some point wants to recover my image on an other computer, the recipe will break, because of the rater rare image I used is gone.

This is always a risk when using Docker recipe’s, but the risk seems to increase now.

Docker does not have anything like that configured out of the box. There are commands to purge and prune unused images, containers and all that on the command line but there is no machinery to execute them frequently. Also, they may be either a bit hungry with deleting stuff or soft for your particular needs. As an example, you can filter containers to be removed if they were created more than a day ago:

docker container prune --filter “until=24h”
The caveats are up to you however. It is very likely that the front-end load balancer was created a year ago and only the configuration changed. Or what if it migrated to another host two weeks ago?

Many people have solved this problem for their needs and there are some pre-existing solutions. There are guides of varying quality available, mostly listing the required commands.

If you use an official image as in your example then there is no such risk.

@tekki Thanks for the clarification.

You may also want to consider a private registry. Not only would that somewhat mitigate the new rules but, more importantly, remove an external dependency from your application deployment process. Of course doing so does add to your own maintenance burden but that is really a balance of risks between relying on the availability of an external registry vs. being able to guarantee that you will always have access to an image (especially for production deployment).