Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Build stage volumes #38366

Closed
dhanvi opened this issue Dec 13, 2018 · 2 comments
Closed

Proposal: Build stage volumes #38366

dhanvi opened this issue Dec 13, 2018 · 2 comments
Labels
area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@dhanvi
Copy link

dhanvi commented Dec 13, 2018

It would be great to have build stage volumes so that we can copy data while building the container it's self without having to wait for the image to be build.

Proposal:

FROM ubuntu

VOL /mnt/data/ /data/
RUN apt-get install build-essentials
ADD . /src
RUN cd /src && make && cp binary /data/
@thaJeztah thaJeztah added area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny labels Dec 14, 2018
@thaJeztah
Copy link
Member

Looks related to #14080, and #32507 which is about the RUN --mount feature that is now available as an experimental Dockerfile syntax (also see #3056 (comment) and the Dockerfile frontend experimental syntaxes)

I don't think this is something we'd want to have in the Dockerfile; the Dockerfile by itself should not be able to write to arbitrary locations on the host. The Dockerfile is intended to produce a Docker image as artefact, and not a binary (or files) on the host.

Note that BuildKit itself (which will be used as the next generation backend for docker build, and can now be used in Docker 18.06 and up) is able to use a different "exporter" to produce a "local" artefact instead of an image.

For your use-case; it looks like you don't want the image itself as result, but have the binary built inside a container, and the result copied to your host, correct?

Instead of using docker build for this, you could consider using docker run to build the artefacts, and bind-mount a local directory to get the results?

Create your base image with the build-tools installed;

docker build -t mybuildimage -<<EOF
FROM ubuntu:18.04
RUN apt-get update && apt-get -y install build-essentials
EOF

Then docker run your image, and copy the results to a bind-mounted directory;

docker run -it --rm \
  -v $(pwd):/src \
  -v /mnt/data/:/data/ \
  --workdir=/src \
  mybuildimage bash -c 'make && cp binary /data/'

@dhanvi
Copy link
Author

dhanvi commented Dec 14, 2018

I agree with you.

My use-case was to easily copy files from container to host system at the build time, RUN --mount should do the job for me.

I have raised issues for the same solution suggested by you. docker/cli#1568 #38197

Apologies for not doing enough research on already existing issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests

2 participants