Docker Community Forums

Share and learn in the Docker community.

How to mount volume created during build?

build

(Saul Shanabrook) #1

Is it possible to mount a volume during docker build, with the VOLUME dockerfile command?

I am using Docker for Mac and want to be able to mount that volume on my host system, so that I can access those files on my host files system.


(Think) #2

ADD / COPY within the Dockerfile also could access your host system. They access the place where you invoked the docker build command.
@saulshanabrook: Isn’t that sufficient for your usecase?


(Saul Shanabrook) #3

I am using this workflow to mount my source code after a npm install. I then want to extend it and mount the node_modules that were installed in the docker image, back in my host system, so that my intellisense editor can pick up the installed files.


(Andrewsmithty) #4

i want to do a very similar thing as @saulshanabrook, only with java/maven

in the docker file i am doing a RUN mvn clean compile
which in turn ALWAYS pulls down all the dependencies for my project.
i really would love to see a build time volume mount, where i could mount in my host machine’s ~/.m2 folder to speed up the image build.

my ~/.m2 folder currently is about 10GB big, so ADD/COPY -ing it to the image is not an option.