docker run -it -v /data --name=container1 busybox sh
exit
docker volume ls
DRIVER VOLUME NAME
local 2b44e16bfe8a7417e6ef183e9b9824936a490bff0c4122568437a449f85d52a1
local 283861498c6d94b05dfed40237066e05e955f916ae94e6ac8c5a9070d8dcc058
docker start container1
docker inspect container1
讓 Container 和 Container 之間的資料共享
啟動第二個 Container 指令如下
docker run -it --volumes-from container1 --name=container2 busybox sh
root@kawsing:/# cd /var/lib/docker/volumes/2b44e16bfe8a7417e6ef183e9b9824936a490bff0c4122568437a449f85d52a1/_data/
root@kawsing:/var/lib/docker/volumes/2b44e16bfe8a7417e6ef183e9b9824936a490bff0c4122568437a449f85d52a1/_data# ls
helloworld2.txt helloworld.txt
新增一個named volume
docker volume create --name data
docker volume ls
真實路徑位於/var/lib/docker/volumes/data/_data
再次啟動容器
docker run --name testvolume -v data:/tmp -itd busybox sh