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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With