码迷,mamicode.com
首页 > 其他好文 > 详细

docker镜像容器导入导出

时间:2016-05-17 11:42:39      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:docker容器导出导入 docker镜像导出导入

记录一下,省的以后自己老忘。


ubuntu-14.04-x86_64.tar.gz是下载的模板文件,导入模板文件示例如下

root@zxl-node4:~# ll ubuntu-14.04-x86_64.tar.gz 
-rw-r--r-- 1 root root 154056446 May 17 10:04 ubuntu-14.04-x86_64.tar.gz
root@zxl-node4:~# cat ubuntu-14.04-x86_64.tar.gz | docker import - ubuntu_template:v1
b4ebc953c6f45c7be7d12bc226ad4fe445c97a9589bb714c31d205a7a9fcc686
root@zxl-node4:~# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu_template         v1                  b4ebc953c6f4        43 seconds ago      415.7 MB


镜像导出为ubuntu_haha.tar

root@zxl-node4:~# docker save -o ubuntu_haha.tar ubuntu:latest
root@zxl-node4:~# ll ubuntu_haha.tar 
-rw-r--r-- 1 root root 197043712 May 17 10:03 ubuntu_haha.tar


镜像导入,把ubuntu_haha.tar镜像导入名字为ubuntu_haha:v1

root@zxl-node4:~# cat ubuntu_haha.tar | docker import - ubuntu_haha:v1
8955fbb15571dd4621f270363238d8859fc6a5e2ee797b8267e86abdbc50f9f7


查看导入后的镜像

root@zxl-node4:~# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu_haha             v1                  8955fbb15571        22 seconds ago      197 MB


注:镜像导入还可以使用一下命令

docker load < ubuntu_haha.tar
或者
docker load --input ubuntu_haha.tar




容器导出,bff3c385e273容器的ID,导出后容器的文件名ubuntu_x1.tar

docker export bff3c385e273 > ubuntu_x1.tar



容器导入成为镜像

cat ubuntu_x1.tar | docker import - ubuntu_x1:v1


本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1774231

docker镜像容器导入导出

标签:docker容器导出导入 docker镜像导出导入

原文地址:http://noodle.blog.51cto.com/2925423/1774231

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!