您现在的位置是:首页 > 文章详情

docker数据拷贝

日期:2016-04-25点击:625

docker数据拷贝的方式有很多种,下面介绍几种数据拷贝的方式;此处只是介绍几种简易的方式,更多方式可以google下。

从容器中向主机拷贝数据

docker cp <containerId>:/file/path/within/container /host/path/target  docker cp 8e7e5f4574f4:/root/test.txt ./test.txt

 

从主机向容器中拷贝数据

docker cp /host/path/target <containerId>:/file/path/within/container docker cp ./host.txt 8e7e5f4574f4:/root/host.txt

用-v挂载主机数据卷到容器内

docker run -v /path/to/hostdir:/mnt $container

其余的在宿主机上操作即可

通过输入输出符进行拷贝

docker run -i ubuntu /bin/bash -c 'cat > /path/to/container/file' < /path/to/host/file/ # 或者 docker exec -it <container_id> bash -c 'cat > /path/to/container/file' < /path/to/host/file/
原文链接:https://yq.aliyun.com/articles/319317
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章