Skip to content

Passing build args in multi-stage build using a terminal stage dockerfile #1009

@rverma-nikiai

Description

@rverma-nikiai

This is a feature suggestion, which I believe would be much useful.

Consider scenario as there is a util (e.g brew) which can install multiple packages

FROM alpine:3.7 as build

ONBUILD ARG CLOUD
ONBUILD RUN if [ "${CLOUD}" = "aws" ]; then echo 'installing aws'; fi
ONBUILD RUN if [ "${CLOUD}" = "gce" ]; then echo 'installing gce'; fi

As a consumer of this utility, I can install the utilities from the base image, while adding multiple utilities of mine also;

FROM my-onbuild
RUN echo 'installing my-super-cool-aws-util'

But at final step I would need to build my image as
docker build --build-arg CLOUD=aws -t cool .

It would be nice to have if from final Image (cool here) I define those args within docker file,
and they are automatically added to build context's args even for builder image

FROM my-onbuild
ARG CLOUD=aws
RUN echo 'installing my-super-cool-aws-util'

Raising it in cli repo as 1 quick way to handle this is, scan the current docker file add all non-null args as build-args (if not already added).

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions