一、通过dockerfile 挂载数据卷
1、创建dockerfile,内容如下:
[root@master home]
/home
[root@master home]
FROM centos
VOLUME ["v01", "v02"]
CMD echo "----end-----"
CMD /bin/bash
[root@master home]
2、通过dockerfile 创建镜像
[root@master home]
Sending build context to Docker daemon 7.168kB
Step 1/4 : FROM centos
---> 300e315adb2f
Step 2/4 : VOLUME ["v01", "v02"]
---> Running in 0be5372c2d95
Removing intermediate container 0be5372c2d95
---> db5ead0a07a1
Step 3/4 : CMD echo "----end-----"
---> Running in 74d2af77f420
Removing intermediate container 74d2af77f420
---> 16cd42f93d