Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - multiple volumes inside the dockerfile

I am trying to add multiple to VOLUME, but it doesn't seem to work as expected. Here is my docker file.

FROM maven:3.6.1-jdk-8 as maven-build

VOLUME /apps/demo/conf
VOLUME /apps/demo/docs
VOLUME /apps/demo/logs

After the docker image is created, I ran it. I don't see the file inside the docker filesystem that I created on the host machine under /apps/demo/conf.

I know I can pass it through the command line through 'docker run -v path:path, but I am wondering if there is a way to do it inside the Dockerfile.

like image 589
user826323 Avatar asked Apr 01 '26 05:04

user826323


1 Answers

VOLUME X in a Dockerfile doesn't mean mount X from the host system. All this is doing is telling Docker to persist data written to /apps/demo/conf from within the container in a host directory. You might do that if you wanted to persist some data across container restarts for instance. If you want to mount a host filesystem within the container, you must use run -v as you said.

like image 163
chash Avatar answered Apr 02 '26 18:04

chash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!