'Docker output file and docker image during build (multistage build)
I'm using multistage build to get output files from build phase. So my dockerfile is:
FROM ... AS build-stage
...
FROM scratch AS export-stage
COPY --from=build-stage /app/a.out /
And my 2 commands to build are:
DOCKER_BUILDKIT=1 docker build \
-t `cat Dockerfile.tag` \
-f Dockerfile \
--output type=local,dest=output_docker .
and
DOCKER_BUILDKIT=1 docker build \
-t `cat Dockerfile.tag` \
-f Dockerfile .
I'm ok, with output files, but I would like to get working docker image, so when I run command docker run -it <docker_image_from_build> /bin/bash, I'm getting following error:
docker: Error response from daemon: failed to create shim: OCI runtime create failed:
container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash:
no such file or directory: unknown.
ERRO[0000] error waiting for container: context canceled
As I understand second command to build image is outputing export-stage, which is almost empty image. How to bypass this issue?
Solution 1:[1]
Ok, I think this should be ok: https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
So build command is getting argument, to build proper stage, in my case this is only build-stage.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 404pio |
