cli icon indicating copy to clipboard operation
cli copied to clipboard

Include Keyword to use partial Dockerfiles

Open GitRon opened this issue 7 years ago • 2 comments

Hi guys,

maybe I'm doing something wrong but I was really missing one feature.

As a programmer I always have the goal to work DRY. Unfortunately if I need a specific part of Dockerfile-code in multiple Dockerfiles, I have to copy it around.

It would be great if there wouldbe an INCLUDE keyword I could use in my Dockerfile.

Example:

FROM alpine:latest

COPY . /var/my-dir

INCLUDE ./Dockerfile.partial

[...]

And this partial Dockerfile contains regular Dockerfile code. My current workaround is loading a bash script which is not as nice as using Dockerfile syntax.

Best regards Ron

GitRon avatar Jan 22 '19 10:01 GitRon

+1 this would be a useful addition.

johl-moto avatar Jul 03 '19 03:07 johl-moto

Could you stop at a specific build stage then use the intermediate image as the starting point in another dockerfile?

https://docs.docker.com/build/building/multi-stage/#stop-at-a-specific-build-stage

KarsonAlford avatar Jan 16 '24 19:01 KarsonAlford