docker-multi-stage-build

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

给你一囗甜甜゛ 提交于 2019-12-10 16:03:10
问题 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

Docker compose and external images multi-stage builds

丶灬走出姿态 提交于 2019-12-06 02:45:22
I use Docker multi-stage build , specifically: Use an external image as a “stage” When using multi-stage builds, you are not limited to copying from stages you created earlier in your Dockerfile. You can use the COPY --from instruction to copy from a separate image, either using the local image name, a tag available locally or on a Docker registry, or a tag ID. The Docker client pulls the image if necessary and copies the artifact from there. The syntax is: In my case I have three Docker files. One Dockerfile simply defines an image, which I use as a build stage to share among two other

How can I cache Maven dependencies and plugins in a Docker Multi Stage Build Layer?

心已入冬 提交于 2019-12-06 02:38:06
问题 I want to cache Maven dependencies in a layer of the build stage of my Docker Multi Stage Build. My Dockerfile looks as follows: FROM maven:3-jdk-8 as mvnbuild RUN mkdir -p /opt/workspace WORKDIR /opt/workspace COPY pom.xml . RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml dependency:resolve COPY . . RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package FROM openjdk:8-jre-alpine ... ``` I based this Dockerfile on the example provided in the Docker Multi Stage Build blog post

How do I copy variables between stages of multi stage Docker build?

故事扮演 提交于 2019-11-29 20:02:23
问题 I've only seen examples of using COPY to copy files between stages of a multi stage Dockerfile, but is there a way to simply copy an ENV variable? My use case is to start out with a git image to just to get the commit hash that will be part of the build. The image I'm later building with hasn't got git. I realise I could just pipe out the git hash to a file and use COPY but I'm just wondering if there's a cleaner way? 回答1: You got 3 options: The "ARG" solution, the "base" solution, and "file"