python -m json.tool 可以将输出的json字符串格式化显示。
Source 表示主机上的目录,即 /tmp/source 。
Destination 为容器中的目录,即 /tmp/destination。
3. 本机文件可以同步到容器
在本机/tmp/source目录中新建hello.txt文件
touch /tmp/source/hello.txtls /tmp/source/hello.txt
hello.txt文件在容器/tmp/destination/目录中可见
使用 docker exec 命令,可以在容器中执行命令。
docker exectest ls /tmp/destination/hello.txt
所以在宿主机对目录 /tmp/source/ 的修改,可以同步到容器目录 /tmp/destination/ 中。
4. 容器文件可以同步到宿主机
在容器/tmp/destination目录中新建world.txt文件
docker exec test touch /tmp/destination/world.txtdocker exec test ls /tmp/destination/hello.txtworld.txt
world.txt文件在宿主机/tmp/source/目录中可见
ls /tmp/source/hello.txt world.txt
更多相关教程,请关注PHP中文网docker教程栏目。
以上就是docker重启后数据是否会丢失的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
更多相关阅读请进入《Docker》频道 >>