Mounting multiple volumes on a docker container?

2019-01-21 02:41发布

I know I can mount a directory in my host on my container using something like

docker run -t -i -v '/on/my/host:/on/the/container' ubuntu /bin/bash

Is there a way to create more than one host-container pair? e.g. a comma-separated list, or pass in an array?

标签: docker
4条回答
聊天终结者
2楼-- · 2019-01-21 03:29

You can have Read only or Read and Write only on the volume

docker -v /on/my/host/1:/on/the/container/1:ro \

docker -v /on/my/host/2:/on/the/container/2:rw \
查看更多
我只想做你的唯一
3楼-- · 2019-01-21 03:34

You can use -v option multiple times in docker run command to mount multiple directory in container:

docker run -t -i \
  -v '/on/my/host/test1:/on/the/container/test1' \
  -v '/on/my/host/test2:/on/the/container/test2' \
  ubuntu /bin/bash
查看更多
4楼-- · 2019-01-21 03:38

Or you can do

docker run -v /var/volume1 -v /var/volume2 DATA busybox true
查看更多
我只想做你的唯一
5楼-- · 2019-01-21 03:39

Pass multiple -v arguments.

For instance:

docker -v /on/my/host/1:/on/the/container/1 \
       -v /on/my/host/2:/on/the/container/2 \
       ...
查看更多
登录 后发表回答