Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Docker execute the entrypoint when a container is used in a multistage build?

If define a multistage Dockerfile like so:

FROM exampleabc:latest
COPY app.go .


FROM alpine:latest  
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
CMD ["./app"]

Would the exampleabc:latest have it's entrypoint executed?

like image 454
Chris Stryczynski Avatar asked Nov 14 '17 17:11

Chris Stryczynski


People also ask

How does Docker multi stage build work?

With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don't want in the final image.

Does Docker build run ENTRYPOINT?

ENTRYPOINT instructions are used to build Dockerfiles meant to run specific commands. The above Dockerfile uses an ENTRYPOINT instruction that echoes Hello, Darwin when the container is running.

What happens if multiple ENTRYPOINT instructions are specified in one single stage Dockerfile?

What happens if multiple ENTRYPOINT instructions are specified in one, single-stage Dockerfile? Only the first ENTRYPOINT instruction has any effect. The build will fail.

Can Docker container have multiple processes?

It's ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.


1 Answers

From official documentation:

Only the last ENTRYPOINT instruction in the Dockerfile will have an effect.

like image 136
SiKing Avatar answered Nov 15 '22 05:11

SiKing