Questions tagged [docker-multi-stage-build]

1

votes
1

answer
665

Views

Docker: How to use multistage images after build finishes

Scenario Multistage builds combine multiple Dockerfile sections into a single one Intermediary and final stages can copy files from the upper stages Final stage is suggested to have only the binaries needed. With those in mind, I'd like to build the follow FROM fat-base as build RUN setup unit test...
Marcello de Sales
1

votes
1

answer
272

Views

Docker Multi-Stage: How to split up into multiple Dockerfiles

I am successfully using Docker's Multi-Stage feature to build some code and then copy the resulting artifacts into a final image. Is it possible to split this one big-ish Dockerfile into multiple files? I would like to improve the readability of the individual stages. Which will become more importan...
Unapiedra
1

votes
2

answer
244

Views

Multi-stage Dockerfile: ARG before FROM not substituted

I'm writing a multi-stage Dockerfile for the darshan utils: ARG DARSHAN_VER=3.1.6 FROM fedora:29 as build RUN dnf install -y \ gcc \ make \ bzip2 bzip2-devel zlib zlib-devel RUN curl -O 'ftp://ftp.mcs.anl.gov/pub/darshan/releases/darshan-${DARSHAN_VER}.tar.gz' \ && tar ... FROM fedora:29 COPY --from...
Alberto Chiusole
1

votes
1

answer
432

Views

Shared build logic with docker-compose and multi-stage Dockerfiles

I am using docker-compose with multi-stage Dockerfiles to build and run multiple services. This works, but the 'build' portion of each multi-stage build is largely copy-and-pasted between each service's Dockerfile. I want to reduce the copy-and-paste / centralize the common build logic in one spot....
LegNeato
1

votes
1

answer
260

Views

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 /destination/ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuf...
brance
1

votes
0

answer
28

Views

With Docker, what files persist between stages?

There are few ways in which I can phrase my question. I find documentation lacking around how to use an artifact from a previous stage - specifically the example here. My use case is I'm using a docker stage to makepkg an arch linux package, which requires many build-time dependencies (including a 5...
haelix
1

votes
2

answer
293

Views

How can I use microk8s with newer Docker?

I'm currently running microk8s in it's stable form (v1.12.0) on my Ubuntu 18.04 installation. It comes with a Docker 17.03.2-ce, which lacks support for multi-stage builds, added in Docker 17.05. The microk8s documentation advises not to use any other Docker on the system (at least as long as AppArm...
Peter Becker
1

votes
1

answer
87

Views

Docker: How to share the same application code between multiple containers/services (e.g. PHP-FPM and NGINX)

tl;dr application code requires a build-step (pull in dependecies) multiple containers need the same 'built' code Q: what's a good strategy / workflow to archive that with docker / docker-compose. Long We're in the process of dockerizing a PHP application with mutiple components (containers/services...
Hirnhamster
1

votes
1

answer
808

Views

Cryptography Python Docker multistage build

I have a Python project that runs in a docker container and I am trying to convert to a multistage docker build process. My project depends on the cryptography package. My Dockerfile consists of: # Base FROM python:3.6 AS base...
Jon G
1

votes
1

answer
79

Views

Multi stage Dockerfile leads to running out of space

As my code (nodeJS-application) is changing more often than the (npm) dependencies do, I've tried to build something like a cache in my CI. I'm using a multi-stage Dockerfile. In that I run npm install for all, and only, prod dependencies. Later they are copied to the final image so that it is much...
user3142695
1

votes
1

answer
39

Views

Select angular.json configurations during docker multistage build

I'm building the angular6 app w/ a docker multistage build. The default angular.json created by angular.cli contains a build section including a list of configurations. I can select a specific configuration using the following command ng build --configuration production but in my docker multistage...
Crixo
1

votes
1

answer
0

Views

Empty multi-stage build in a Dockerfile

I understand the purpose of using a multi-stage build but I cannot understand why you would like to have an empty stage like this? Can someone please elaborate on the use-case? # Use an official Ubuntu 18.04 as parent image FROM ubuntu:18.04 # Install python 2.7 FROM python:2.7 RUN apt-get update R...
user3504575
1

votes
2

answer
487

Views

Import Dockerfile from different local directory via FROM

I want to create a multistage build process whereas each of the docker files are nested inside their own directories locally with their corresponding dependencies that are ADDed in for each Docker file. Is there a way to import a Docker file from a different directory locally whereas I am able to im...
Baily
1

votes
1

answer
250

Views

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

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/l...
TafT
2

votes
1

answer
835

Views

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 IMAGE_ONE=debian:7 --build-arg IMAGE_TWO=debian:8 ....
segfault
8

votes
3

answer
2.9k

Views

dockerfile multistage build for python, reducing image size

I am looking for a way to create multistage builds with python and Dockerfile I.e what I'm trying to do is creating a Dockerfile using few images: 1st image: install all compile time requirements, and install all needed python modules 2nd image: copy all compiled / built packages from first image to...
gCoh
5

votes
1

answer
368

Views

Docker Multi-stage Builds and Test results - How to get them?

Apparently, all articles I found about multi-stage builds cover the happy path. But how to get the test results (e.g. unit or acceptance tests) out of a builder-container when something fails?
Arman
1

votes
2

answer
204

Views

Docker multistage build for golang create big image

I want to use the multi stage build for my gaoling project, when I build the project locally for linux/windows/Mac I got 12.6 mb of size , I’ve currently small gaoling CLI program. Now I want to build it with to build from it lightwhigt docker image with the scratch option and build as I use the f...
Jenny M
5

votes
3

answer
148

Views

Docker multi-stage-build with different project

We are working with two project at the moment: 1 C++ based project 2 Nodejs based project These two projectes are separated which means they have different codebase(git repoitory) and working directory. C++ project will produce a node binding file .node which will be used by Nodejs project. And we t...
hguser
4

votes
2

answer
1.7k

Views

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

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...
Trastle
2

votes
2

answer
304

Views

Why does the ASP.NET Core Multi-Stage Dockerfile use 4 Stages

This is the default multi-stage Dockerfile when you click on 'Add Docker Support' in Visual Studio on an ASP.NET Core site. FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src COPY WebApplication1.sln ./ COPY WebApplication1/WebAppli...
2

votes
1

answer
328

Views

Why is my final docker image in this multi-stage build so large?

After reading about the enormous image size reductions that are possible with multi-stage docker builds, I'm attempting to slim down the image size for a Dockerfile I have for building a Go binary. My Dockerfile is below. # Configure environment and build settings. FROM golang:alpine AS buildstage...
2

votes
1

answer
429

Views

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 ${HOME}/local/bin:${PATH}:/home/site/wwwroot RUN cd /var/www/html && \ npm install && \ npm run pr...
1

votes
1

answer
40

Views

Docker muti-stage

Hello people of the internet, does anyone know how or if it is possible to copy one stage of a multi-stage Dockerfile into another? For various business reasons I have been instructed to use a multi-stage Dockerfile, but what I really need to do is combine the appserver image and webserver image. Th...
nmcilree
5

votes
1

answer
776

Views

Use multi-stage docker files for outputting multiple images

A new docker feature is to do something like this in the dockerfile FROM php7-fpm as build ... FROM build AS test ... FROM test AS staging ... As far as i know, the last FROM statement marks the final output image. How is it possible to have two final images from one intermdiate image? Like ... FROM...
Jim Panse