Questions tagged [docker-multi-stage-build]
221 questions
4
votes
2 answers
docker-compose does not start the specified stage
I am trying to create a multi stage Dockerfile, where the first stage is meant to be started in development environment (simple dev server) and the second stage is meant for production (full size web server).
FROM python:3.9-alpine3.14 as…

Paweł Lis
- 125
- 8
4
votes
2 answers
Dockerfile build from source in one stage and then copy and install in second stage
I'm a novice to docker and to linux.
Im running on a Alpine base image and I want to keep my image as clean and lightweight as possible. I have to build and install some packages in my Dockerfile, specifically this.
I was wondering if there was any…

Ehsas
- 69
- 1
- 5
4
votes
1 answer
How to use maven local repository in Multi-stage docker build?
I've been trying to create a multi-stage docker build for my spring-boot-application. The problem is on every change on the master branch, the pom.xml file changes (thanks to maven release plugin), so it's kind of hard to make use of docker…

omjego
- 373
- 2
- 5
- 15
4
votes
1 answer
Persist ENV vars across multi-stage Docker builds
Last time I checked, when I did this:
FROM x:latest
ENV foo 'bar'
FROM y:latest
RUN echo "$foo"
then "echo $foo" was empty - is there a way to persist ENV vars across multi-stage builds?
user7898461
4
votes
1 answer
Multistage build image not working, while normal build does
I have a Dockerfile that builds a golang project (that listens to the Twitter stream and lists the tweets by some filter) from the latest golang docker image, right now 1.10.3, like so:
FROM golang:1.10.3
COPY . /destination/
WORKDIR…

brance
- 1,157
- 9
- 22
4
votes
1 answer
Docker multistage build doesn't recognise installed application
FROM some-build:latest as build
COPY / /var/www/html
WORKDIR /var/www/html
RUN cd /var/www/html && composer install
FROM some-build2:latest as run
COPY --from=build /var/www/html /var/www/html
ENV PATH…

Infinite Possibilities
- 7,415
- 13
- 55
- 118
4
votes
1 answer
docker multistage build fails with multiple --build-arg
I am using this Dockerfile
ARG IMAGE_ONE
FROM ${IMAGE_ONE}
RUN cat /etc/debian_version
ARG IMAGE_TWO
FROM ${IMAGE_TWO}
RUN cat /etc/debian_version
But it fails because it does not use the second var IMAGE_TWO:
$ docker build --no-cache --build-arg…

segfault
- 41
- 1
- 4
3
votes
1 answer
Why docker needs to build all the previous stages?
I need to build 2 stages based on a common one
$ ls
Dockerfile dev other prod
$ cat Dockerfile
FROM scratch as dev
COPY dev /
FROM scratch as other
COPY other /
FROM scratch as prod
COPY --from=dev /env /
COPY prod /
As you can see prod stage…

Pierre de LESPINAY
- 44,700
- 57
- 210
- 307
3
votes
1 answer
Cache issue when building a multi-stage image with kaniko
I've setup container images builds in kubernetes using kaniko (version v1.6.0-debug), but I ended up in the following problem when the cache is enabled (/kaniko/executor --cache --cache-repo $CI_REGISTRY_IMAGE/cache).
This is a simplified Dockerfile…

Davide Madrisan
- 1,969
- 2
- 14
- 22
3
votes
1 answer
Disadvantages of docker --squash
I wanted to know about the disadvantages of docker --squash in a production environment. The reason why I am using this command is:
I needed dependencies(gcc,make,autoconf, etc) to build my PHP-react project. Also, I have created my own PHP base…

1nfern0
- 131
- 4
3
votes
0 answers
How to use docker postgres as base image in Dockerfile?
I need to run a golang web server with postgres.
I wanted to put everything into one Docker image but don't know how to run database in the background.
Dockerfile
# Build Backend
FROM golang:1.16.3-alpine3.13 AS server-builder
WORKDIR /go/src
COPY…

Huakun Shen
- 312
- 2
- 9
3
votes
0 answers
Docker multistage ONBUILD not executing first stage onbuild commands
I'm trying to create a multistage ONBUILD image for a Java project, see the example below. First iteration only seems to see the ONBUILD command in the last stage while inspecting the build result.
FROM maven:3.6.3-jdk-11-slim AS build
RUN mkdir…

Bas Koopmans
- 341
- 4
- 14
3
votes
2 answers
How to use multistage build on node docker file
I am using this docker file to give a simple hello world output on the browser. The docker file copies in the package.json(which already has express defined on it) and the index.json(which uses the express framework to display hello world)
Currently…

trying2dev
- 51
- 5
3
votes
0 answers
Running tests as part of Docker build in ASP.NET Core
I'm trying to run unit tests as part of the docker build process, and I stumbled upon two resources:
.NET Core Multi-Stage Dockerfile with Test and Code Coverage in Azure Pipelines
Running .NET Core Unit Tests with Docker and Azure Pipelines…

Farzad
- 1,770
- 4
- 26
- 48
3
votes
0 answers
Docker build timestamps
Is it possible to get step timestamps in a console/log file while running docker build command?
Step 28/49 : RUN find dist -name "*.map" -delete
---> Running in 5e1ee1063999
Removing intermediate container 5e1ee1063999
---> a02191df133c
Step…

Zygimantas
- 8,547
- 7
- 42
- 54