Posts

Showing posts from January 13, 2019

How to COPY library files between stages of a multi-stage Docker build while preserving symlinks?

Image
1 I have a Dockerfile which is split into a two-stage multi-stage docker build. The first stage generates a basic gcc build environment in which a number of C and C++ library are compiled. The second stage uses the COPY --from= command to copy the library files from the first stages /usr/local/lib/libproto* to the current image's. The problem I am seeing is that the first image contains symlinks from a generic library file name to a specific versioned file name. AFAIK this is common practice within Debian and many other Linux systems. Docker's COPY command does not seem to understand symlinks so instead makes two complete copies of the library files. This results in a larger Docker Image size and warnings from later apt-get commands to the tune of ldconfig: /usr/local/lib/libprotobuf.so.17 is no