1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 创建data目录 [root@localhost ~]# mkdir /data/ [root@localhost data]# docker run -itd -v /data/:/data01/ centos bash d0140fb14f36629e193e0100e39e607ffa4359fb8beb2a07fdbcd747acdad5d1 进入d014系统 [root@localhost data]# docker exec -it d014 bash 查看挂载情况: [root@d0140fb14f36 /]# df -Th Filesystem Type Size Used Avail Use% Mounted on rootfs rootfs 9.8G 360M 8.9G 4% / /dev/mapper/docker-253:0-525066-d0140fb14f36629e193e0100e39e607ffa4359fb8beb2a07fdbcd747acdad5d1 ext4 9.8G 360M 8.9G 4% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev shm tmpfs 64M 0 64M 0% /dev/shm /dev/mapper/VolGroup-lv_root ext4 50G 5.8G 41G 13% /data01 /dev/mapper/VolGroup-lv_root ext4 50G 5.8G 41G 13% /etc/resolv.conf /dev/mapper/VolGroup-lv_root ext4 50G 5.8G 41G 13% /etc/hostname /dev/mapper/VolGroup-lv_root ext4 50G 5.8G 41G 13% /etc/hosts tmpfs tmpfs 1.9G 0 1.9G 0% /proc/kcore tmpfs tmpfs 1.9G 0 1.9G 0% /proc/timer_stats [root@d0140fb14f36 /]# 进入data01目录创建数据文件 [root@d0140fb14f36 /]# cd /data01/ [root@d0140fb14f36 data01]# ls [root@d0140fb14f36 data01]# touch a.txt [root@d0140fb14f36 data01]# touch b.txt [root@d0140fb14f36 data01]# 查看宿主机data目录文件是否已完成创建: [root@localhost data]# cd /data/ [root@localhost data]# ls a.txt b.txt [root@localhost data]# |