Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to bind multiple folders in Docker?

Tags:

docker

Is it possible to bind multiple folders in Docker?
For example, like ports:

-p 3000:3000 -p 3022:22

The idea seems like:

-v path:path -v path2:path2

Is this possible?

like image 333
Rys Avatar asked Jan 08 '23 11:01

Rys


2 Answers

No problem at all. You can specify files and directories like in this example taken from a tomcat container to blend in certificates. (:ro is optional for read only)

-v $(pwd)/secret-files/certificates/verisign.keystore:$CONFIG_PATH/certificates/verisign.keystore:ro \
-v $(pwd)/secret-files/certificates/fuse/:$CONFIG_PATH/certificates/fuse/:ro \
like image 108
christian Avatar answered Jan 15 '23 18:01

christian


Docker allows mounting (or binding) multiple folders. Here is the Docker documentation which clearly mention this : link

-v, --volume=[] Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)

You can add a data volume to a container using the -v flag with the docker create and docker run command. You can use the -v multiple times to mount multiple data volumes.

Example (from what I do) :

docker run -v /opt/rpms:/opt/rpms/ -v /export/centos6_1/app/logs:/export/centos6_1/app/logs -t -i centos6_1 /bin/bash
like image 43
spectre007 Avatar answered Jan 15 '23 19:01

spectre007