

Fight Docker Package Drift!
source link: https://zwischenzugs.com/2015/02/21/fight-docker-package-drift/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fight Docker Package Drift!
zwischenzugs Uncategorized February 21, 2015February 21, 2015
2 Minutes
Fight Docker Package Drift!
The Problem
While Dockerfiles can help enormously with pinning down the details of your build process, you can still fall victim to package drift. This is when package management changes behind the scenes, leaving you with nasty surprises to unpick.
You can specify the versions of your apt packages like this:
apt-get install package=version
but what about that package’s dependencies? And their dependencies? And so on…
“Solution”
The following command installs the given package you’re concerned with, and then spits out a Dockerfile RUN instruction with the specific versions used as dependencies. You can then place this into your Dockerfile, and if the build fails in the future, you’ll know something has changed.
The following example does this for vim, but you can change that package to whatever you like.
$ docker run imiell/get-versions vim RUN apt-get install -y vim=2:7.4.052-1ubuntu3 vim-common=2:7.4.052-1ubuntu3 vim-runtime=2:7.4.052-1ubuntu3 libacl1:amd64=2.2.52-1 libc6:amd64=2.19-0ubuntu6.5 libc6:amd64=2.19-0ubuntu6.5 libgpm2:amd64=1.20.4-6.1 libpython2.7:amd64=2.7.6-8 libselinux1:amd64=2.2.2-1ubuntu0.1 libselinux1:amd64=2.2.2-1ubuntu0.1 libtinfo5:amd64=5.9+20140118-1ubuntu1 libattr1:amd64=1:2.4.47-1ubuntu1 libgcc1:amd64=1:4.9.1-0ubuntu1 libgcc1:amd64=1:4.9.1-0ubuntu1 libpython2.7-stdlib:amd64=2.7.6-8 zlib1g:amd64=1:1.2.8.dfsg-1ubuntu1 libpcre3:amd64=1:8.31-2ubuntu2 gcc-4.9-base:amd64=4.9.1-0ubuntu1 gcc-4.9-base:amd64=4.9.1-0ubuntu1 libpython2.7-minimal:amd64=2.7.6-8 mime-support=3.54ubuntu1.1 mime-support=3.54ubuntu1.1 libbz2-1.0:amd64=1.0.6-5 libdb5.3:amd64=5.3.28-3ubuntu3 libexpat1:amd64=2.1.0-4ubuntu1 libffi6:amd64=3.1~rc1+r3.0.13-12 libncursesw5:amd64=5.9+20140118-1ubuntu1 libreadline6:amd64=6.3-4ubuntu2 libsqlite3-0:amd64=3.8.2-1ubuntu2 libssl1.0.0:amd64=1.0.1f-1ubuntu2.8 libssl1.0.0:amd64=1.0.1f-1ubuntu2.8 readline-common=6.3-4ubuntu2 debconf=1.5.51ubuntu2 dpkg=1.17.5ubuntu5.3 dpkg=1.17.5ubuntu5.3 libnewt0.52:amd64=0.52.15-2ubuntu5 libslang2:amd64=2.2.4-15ubuntu1 vim=2:7.4.052-1ubuntu3
Take that RUN line that was output, and place in your Dockerfile, eg where you had
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y vim
you would now have:
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y vim=2:7.4.052-1ubuntu3 vim-common=2:7.4.052-1ubuntu3 vim-runtime=2:7.4.052-1ubuntu3 libacl1:amd64=2.2.52-1 libc6:amd64=2.19-0ubuntu6.5 libc6:amd64=2.19-0ubuntu6.5 libgpm2:amd64=1.20.4-6.1 [...]
If you try and rebuild this and something has changed, you’re far more likely to catch and identify it early. This should be particularly useful for those paranoid about any kind of changes to their builds. It won’t solve all Docker “build drift” problems, but it is a start.
Source
The source code for this is available here.
Note that this assumes a debian flavour of ubuntu:14.04. If you have a different base image, fork the repo and change the Dockerfile accordingly. Then, from the same directory:
$ docker build -t get-versions . $ docker run get-versions vim
Help Wanted!
There are, I’m sure, plenty of improvements that could be made – maybe even scripts already in existence – to make this more robust and useful.
I’d also like to know if anyone can do this with other package managers.
If you have any ideas, do let me know: [email protected]
Published by zwischenzugs
Recommend
-
45
This article covers how to detect data drift for models that ingest image data as their input in order to prevent their silent degradation in production. Run the example in a complementaryDomino project. Intr...
-
12
In Conversation with David Cancel, CEO, Drift David Cancel puts the “serial” in serial entrepreneur. David has founded a total of...
-
7
Update on hardware clocks and drift I received a comment about Tuesday's post about ssh and clock sync issues and figured it's worthy of an additional public reply.
-
12
Presto Enables Internal Log Data Analysis at Drift ·I’m a Senior Software Engineer in the data group at Drift, a conversational marketing platform that is used for qualifying leads faster, automatically booking meetings and connecting custome...
-
9
The EU wants an investigation of the Switch's Joy-Con 'drift' issues The European Union’s joint consumer program has urged an investigation into the Nintendo Switch Joy-Con drift issue after it received almost 25,000 complaints from acro...
-
9
Mark Mikula Mar 18, 2021 8 Minute Read It’s unfortunately common to have servers in your environment that your co-wo...
-
6
Is ‘brain drift’ the key to machine consciousness?Could this currently inexplicable phenomenon be what's keeping our robots from experiencing reality?
-
7
If you are the lucky owner of a new PS5 console, then DualSense drift is something you should know about and, potentially, expect. ...
-
5
Valve Reveals Fix For Steam Deck Thumbstick Drift
-
7
9 Ways to Fix Joy-Con Drift on Your Nintendo Switch By Dan Helyer Published 15 hours ago If Joy-Con drift is driving you u...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK