首先创建 一个docker
root@ubuntu:~# docker run --rm=true -it -v /leader java:8 /bin/bash
可以查看到挂载的源地址和目标地址
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME
28e9ad4e8cfb java:8 "/bin/bash" 45 seconds ago Up 45 seconds conf
root@ubuntu:~# docker inspect confident_edison
"Mounts": [
{
"Type": "volume",
"Name": "84e30bc3386faa63d90bd5176fc2b41233d75e8ebdcf470768bb39c81652065c",
"Source": "/var/lib/docker/volumes/84e30bc3386faa63d90bd5176fc2b41233d75e8ebdcf470768bb39c81652065c/_data",
"Destination": "/leader",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
多个文件挂载在本机目录
root@ubuntu:~# docker run --rm=true -it -v /storage /leader java /bin/bash
基于数据容器的单主机互联
一个容器直接和另外一个容器进行挂载