I have two folders, let's say /etc/folder1 and /etc/folder2. I want to map them both in the same docker volume. So that I have these two folders in the root of my volume. Is that possible?
What I want is:
/etc/folder1
/etc/folder2
and then /vol1/folder1 and /vol1/folder2
Docker has multiple options to persist and share data for a running container. However, we may need more than one file storage for a running container, for example, to create backups or grant different access. Or for the same container, we may need to add named volumes and bind them to specific paths.
The file or directory is referenced by its absolute path on the host machine. By contrast, when you use a volume, a new directory is created within Docker's storage directory on the host machine, and Docker manages that directory's contents. The file or directory does not need to exist on the Docker host already.
Docker volumes are used to persist data from within a Docker container. There are a few different types of Docker volumes: host, anonymous, and, named.
In the current Docker version, there is a default limitation on the Docker container storage of 10Gb.
Yes:
> mkdir ~/vol1
> mkdir ~/vol2
> touch ~/vol1/file1
> touch ~/vol2/file2
> docker run -it -v ~/vol1:/vol1 -v ~/vol2:/vol2 ubuntu find / -name file*
/vol2/file2
/vol1/file1
...
You can mount multiple volumes into a container, and you can event mount individual files from the host into the container using volumes.
i think it is possible with:
php:
image: imagename
volumes:
-/etc/folder1:/folder1
-/etc/folder2:/folder2
you have to create folder1 & folder2 in your Dockerfile.
...
RUN mkdir folder1 folder2
...
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