Description
When apt-get install receives only a package name, it uses the version available in the distribution’s repository at build time. Pinning a package still leaves the build dependent on the base image and the packages the repository provides.
Potential impact
An untested update can break application compatibility. Keeping an old version pinned can leave security fixes unapplied.
Remediation
- Specify versions using
apt-get install package=versionand review each package when installing several together. - Run
apt-get updatebefore installation in the sameRUNstep, and confirm that the target distribution's repository contains the selected versions. - Review security updates regularly, test them, and update version pins.
Version-specification examples
These snippets show the version syntax. The standard busybox image lacks apt-get, and python=2.7 is historical. For an actual build, use an apt-capable base image and a supported package version available in its repository.
Without a version specification
dockerfile
FROM busybox
RUN apt-get install python
RUN ["apt-get", "install", "python"]
With a version specification
dockerfile
FROM busybox
RUN apt-get install python=2.7
Explanation:
- Without a version: Both the shell and JSON forms leave the version of
pythonunspecified. - With a version:
python=2.7requests that specific version from the repository.