1、docker匿名挂载
docker run -id -v :/aaa/ --name nginx nginx:v1
106f34d33b6f03d82c870aa445e292cb38812a6ef96af66581e12ad868c7b9a5
docker inspect nginx
"Mounts": [
{
"Type": "volume",
"Name": "43a477d21460df2618a6f5a561a006f5eabdd0d6f5978615429c0d9ae277a144",
"Source":
"Destination": "/aaa",
[root@
[root@
总用量 0
[root@
root@106f34d33b6f:/
root@106f34d33b6f:/aaa
root@106f34d33b6f:/aaa
root@106f34d33b6f:/aaa
[root@
总用量 0
-rw-r--r-- 1 root root 0 9月 17 17:04
2、具名挂载
docker run -id -v test:/aaa/ --name nginx nginx:v1
e0a2222d6aba1959359c11d749c57810def30091ce77d4a047a1d1e2ae9cb576
docker volume ls
DRIVER VOLUME NAME
local 2a1e9c8a211bf7e584af0361e42d63cbe7a5e6399c7a5ca3c33f8ccca409164c
local 43a477d21460df2618a6f5a561a006f5eabdd0d6f5978615429c0d9ae277a144
local 62a2d7c4da567923bb56abe19f5b2d564db02da5566830f2ea7b3ff359631516
local 76da52fa23e28944e50e5f9484de21ab36609d539edea9b4ad8c598d87ef2e88
local 803e988df479210c9c44ab272bb8f76da5fe635398fb41ba9982b8db5f968a24
local 1665b16e0ae8d34adb91d1bd118cf6bf5eaf943da374aeb6ee63f51f7d51d464
local test
[root@
[root@
总用量 0
drwx-----x 3 root root 19 9月 17 17:12 test
3、指定目录挂载
docker run -id -v /root/testng/:/aaa/nginx --name nginx nginx:v1
5f9a9aac3955634ce4c208a5ec9fe266b41f1d0bb458ce20f5bde277167d11c5
cd /root/testng/
[root@
[root@
[root@
root@5f9a9aac3955:/aaa/nginx
4、只读/读写模式
[root@
c1b7e24d1b88b6d1ee2fb1daaeb49db1499a73cc01fb4961aad8a4c3ac10477b
[root@
root@c1b7e24d1b88:/
root@c1b7e24d1b88:/abc
touch: cannot touch '': Read-only file system
[root@
472a8fedd8c948af24bea0641ede5e51de5b5eaccd56cdd6b6f4440f9c8c18c8
5、–volumes-from 继承容器的挂载目录
[root@
918e4b61966f2beb8fbeb23cc7ff7ba8628caf72d9c53bda7e8f8f35c1672814
[root@
b6eda7d2a13d57528bda5b5e8e81e1912b201c715c1169955651b36cae21ac39