博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker跨服务器迁移
阅读量:4070 次
发布时间:2019-05-25

本文共 3272 字,大约阅读时间需要 10 分钟。

Docker的备份方式有export和save两种。

export是当前的状态,针对的是容器,docker save 是针对镜像images。

一、镜像的迁移—save
1.镜像保存
登陆到已经部署好镜像的服务器上面,执行以下命令进行导出
[root@mytest2 local]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZEshiyu/centos        tomcat-centos       b61b207a5809        28 minutes ago      1.263 GBdocker.io/centos    latest              2d194b392dd1        7 hours ago         195.4 MBdocker.io/centos    7.3.1611            66ee80d59a68        4 months ago        191.8 MB[root@mytest2 local]# docker save b61b >mytomcat.tar

2.将镜像导入

将刚才导出的镜像上传到你要导入的那台服务器上
[root@mytest local]# scp  mytomcat.tar 192.168.0.4:/usr/local/root@192.168.0.4's password: mytomcat.tar                                                                                                100% 1228MB  49.1MB/s   00:25

执行以下命令镜像导入
[root@mytest local]# ll mytomcat.tar -rw-r--r-- 1 root root 1287580160 Mar  6 16:36 mytomcat.tar[root@mytest local]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE[root@mytest local]# docker load < mytomcat.tarb03095563b79: Loading layer [==================================================>]   204 MB/204 MB1d88d689ca13: Loading layer [==================================================>] 3.584 kB/3.584 kBa997e4440673: Loading layer [==================================================>]  2.56 kB/2.56 kB0a3b6c7be500: Loading layer [==================================================>] 309.5 MB/309.5 MBcee5bf38dfe0: Loading layer [==================================================>] 774.1 MB/774.1 MBLoaded image ID: sha256:b61b207a5809e56150df90e9c419f838c9a0988828773ef33aa2768e589c19c2kB/774.1 MB[root@mytest local]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
             
              b61b207a5809        About an hour ago   1.263 GB[root@mytest local]# docker tag b61b mytomcat:2.0[root@mytest local]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEmytomcat            2.0                 b61b207a5809        About an hour ago   1.263 G
 
二、容器的迁移—export
1.导出容器
[root@mytest2 local]# docker ps -aCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES8578122af714        b61b                "/bin/sh -c '/usr/loc"   56 minutes ago      Up 56 minutes       0.0.0.0:8090->8088/tcp   naughty_bartik[root@mytest2 local]# docker export 8578122af714 > mytomcat_export.tar

2.导入到新的服务器上

同样需要将刚才的导出的容器备份上传到目标服务器上,执行下面的命令

[root@mytest local]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE[root@mytest local]# cat mytomcat_export.tar |docker import - centos:tomcatsha256:b3d5c7409cf020ea3f1ce57865e8e476e878e347963b3da02cab23b1d7464ce2[root@mytest local]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEcentos              tomcat              b3d5c7409cf0        11 seconds ago      1.263 GB

注意:运行导入的镜像的时候必须带command,否则启动报如下错误

[root@mytest ~]# docker run -d -p 8090:8088 b3d5/usr/bin/docker-current: Error response from daemon: No command specified.See '/usr/bin/docker-current run --help'.

转载地址:http://tdhji.baihongyu.com/

你可能感兴趣的文章
NTLDR.DLL丢失的一个解决方法
查看>>
做好工控需要知道的知识
查看>>
GE 90 30 PLC下载配置报错误的一个原因
查看>>
监控软件与S7300通讯(OPC)缓慢
查看>>
服务器、磁盘阵列开关机顺序
查看>>
做百年老店之基础——责任。
查看>>
网上开店之培养忠诚客户
查看>>
2006年中国软件收入规模前100家企业名单
查看>>
给毕业生的忠告
查看>>
2006年培养员工的失败与成功之处
查看>>
管理出效益
查看>>
感谢工程二部的所有员工!!!
查看>>
MINIGUI学习笔记之安装使用
查看>>
MINIGUI与共享内存
查看>>
浮点型(FLOAT)与CHAR型转换
查看>>
何为团队?
查看>>
如何做好一个项目经理?
查看>>
寻求工控、自动化合作者建立工控网站!(长期有效)
查看>>
MiniGUI 2.0.3商业版本安装
查看>>
REDHAT 网络通讯源码
查看>>