Last active
December 3, 2021 19:15
-
-
Save mthalman/e69d5d6ce784956c53c64618338104e2 to your computer and use it in GitHub Desktop.
Get package dependencies of derived container image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Outputs the set of packages that are dependencies of the packages added by a derived container image. | |
| baseTag="debian:buster-slim" | |
| derivedTag="mcr.microsoft.com/dotnet/aspnet:3.1" | |
| containerCmd="apt list --installed 2>/dev/null | grep installed | sed -n 's/^\([^/]*\).*/\1/p' | sort" | |
| deltaPkgs=$(comm -13 <(docker run --rm $baseTag /bin/sh -c "$containerCmd") <(docker run --rm $derivedTag /bin/sh -c "$containerCmd") | tr '\n' ' ') | |
| docker run --rm $derivedTag \ | |
| /bin/sh -c "\ | |
| apt update 1>/dev/null 2>/dev/null && \ | |
| apt install -y apt-rdepends 1>/dev/null 2>/dev/null && \ | |
| apt-rdepends 2>/dev/null $deltaPkgs | grep '^\S.*' | sort" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment