I would like to prepare the environment for a Docker container such that when apt-get upgrade -s runs inside the container its result is the same as if the command were run outside on the host. This is in the context of and in preparation for adding a text collector apt.sh to an existing Prometheus node-exporter. I am already using a Kubernetes DaemonSet to control such containers (pods) in a way similar to an example from GitHub prometheus-community/node-exporter-textfile-collector-scripts.

Judging from its man page, apt-get works with files in /etc/apt, /var/cache/apt, and /var/lib/apt, and so my container mounts those read-only from the host. Currently my host and container run Debian 9 (Stretch) and Debian 10 (Buster) respectively. I account for this by running apt-get upgrade -s outside the container and apt-get upgrade -s -t stretch inside.

However the two runs still produce different results. What am I missing?

  • 1
    quite sure it needs /var/lib/dpkg/status unless it deems the apt cache is up to date – A.B Sep 21 '19 at 20:52

Fro docker official documentation:

Probably the most common use-case for RUN is an application of apt-get. Because it installs packages, the RUN apt-get command has several gotchas to look out for.

Avoid RUN apt-get upgrade and dist-upgrade, as many of the “essential” packages from the parent images cannot upgrade inside an unprivileged container.

If a package contained in the parent image is out-of-date, contact its maintainers. 
  • +1 Hmm ... but then apt-get upgrade -s is quite different from apt-get upgrade. – rookie099 Sep 22 '19 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.