0

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?

rookie099
  • 375
  • 3
  • 14
  • 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

1 Answers1

1

Fro docker official documentation:

APT-GET
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. 
c4f4t0r
  • 5,301
  • 3
  • 31
  • 42