Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to mount a volume on the host during BUILD phase of a docker image?

Tags:

docker

I'm using centos:6 and need to build an image -using Dockerfile- which has a number of rpms installed (Oracle client, in fact). I don't want to copy/add the rpms inside the image, as it will make the image bulky (and I have to remove the rpms after install, anyway).

Is there a way to mount a folder on the host (CentOS, itself) which contains the rpms, on the image, via Dockerfile and/or using any option of "docker build" command, during the BUILD phase?

like image 289
Babak Tourani Avatar asked May 19 '16 15:05

Babak Tourani


People also ask

Can we attach volume to running container?

Cloning From An Existing Container But, if you do need to add a volume to a running container, you can use docker commit to make a new image based on that container, and then clone it with the new volume. Then, you can run the new image, replacing the old image with the cloned one.

Where are Docker volumes mounted?

Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux).


1 Answers

There's no way, according to the docs for build and run as well as from my experience.

Mounting things is done when you're running a container, rather than when building an image.

like image 60
Horia Coman Avatar answered Sep 27 '22 20:09

Horia Coman