One solution is to use the following approach:
- build a base image (or tag an existing one) as e.g.
mybase
- build your software with a Dockerfile starting with
FROM mybase
- then, when you want to test with new libraries, build a new
mybase
image (with those libraries) and rebuild your software
Likewise, when I have a container built on top of Ubuntu, it usually starts with FROM ubuntu:12.04
. In a few months, when 14.04 LTS will be released, I plan to update my Dockerfiles with FROM ubuntu:14.04
.
If for some reasons, you want to update containers that haven't been built with Dockerfiles, there is another way, but it requires more in-depth knowledge of Docker image format, and it is not guaranteed to work in all scenarios.
The other way is to use docker save
on the existing image. It will output a tarball containing all the layers that make up your image. Those layers will be in two groups, that I will arbitrarily call "upper" and "lower" layers. The "lower" layers contain the base system image and the libraries that you want to upgrade. The "upper" layers contain the app that you want to leave untouched. The idea is to set aside the layer.tar
files of the upper layers, then build your new base image (the new version of the lower layers, if you will), then apply the upper layers on top of the new lower layers.
The most difficult parts will be:
- decoding the image ancestry to know which layers you should keep, and in which order you should apply them;
- applying the layers, if they don't only add/replace files, but also delete some.
If you want to explore that route, first,make sure that you understand basics about layers :-)