undocumented apk info --installed so:<lib name> in nginx dockerfile
-
- Offline
- 1 year 8 months ago
- 2016-07-10
Hi,
I've found a very useful apk info command in nginx's official dockerfile, but I can not find anywhere where this feature is documented:
https://github.com/nginxinc/docker-nginx/blob/11fc019b2be3ad51ba5d097b1857a099c4056213/stable/alpine/Dockerfile (line with scanelf and many pipes)
For example, running this command
apk info --installed so:libc.musl-x86_64.so.1
prints out which package owns the library, as you can see it's very useful in a dockerfile to slim down the image size, take a look at the nginx dockerfile:
it first installs all the required packages to compile nginx, adds them to a virtual package (.build-deps) , compiles nginx, finds out which libraries are runtime dependencies (with scanelf --needed ...), then manipulates the output to have on each line something like this:
so:libz.so.1 so:libstdc++.so.6 so:libgcc_s.so.1 so:libc.musl-x86_64.so.1
then feeds each line to apk info --installed (using xargs), which prints out which installed packages provide these libraries. This output is then fed again to apk add to create another virtual package (.nginx-rundeps), to be able to remove only the unneeded build time dependencies of nginx and slim down the size of the final image.
Why isn't something this useful documented anywhere? Or how am I supposed to know this thing even exists? Is this feature deprecated or not supported?