The use case is fairly straightforward. I am dockerizing our local provisioning (which utilizes chef to configure our ubuntu servers). I am using a few data volumes to share host directories that I want as a cache for the docker containers: eg:
docker run -d -P -h docker -v /foo/apt-cache:/var/cache/apt/archives foo:base
However, the debian package files in /var/cache/apt/archives directory keep getting blown out after each package install. Can someone point me to where this happens in docker and a workaround, so I can preserve my apt-get cache nicely across containers?
Thanks in advance
The cache uses the same storage driver as used for image layers. Metadata is stored in databases at /var/lib/docker/buildkit .
Apt-Cache-ng is A caching proxy. Specialized for package files from Linux distributors, primarily for Debian (and Debian based) distributions but not limited to those. A caching proxy have the following benefits: Lower latency. Reduce WAN traffic.
Docker uses a layer cache to optimize and speed up the process of building Docker images. Docker Layer Caching mainly works on the RUN , COPY and ADD commands, which will be explained in more detail next.
With Docker layer caching, you can save individual layers of the Docker images you build so that they can be reused in subsequent pipeline runs. Docker layer caching can save your team significant time during the build process by bypassing some or all of the image build steps.
sharing /var/cache/apt/archives seems a fragile solution. Maybe you should give a try to setting up a container running apt-cacher-ng and configure apt on your other containers to use that proxy.
Docker has an article explaining how to set this up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With