需求:甲机器内的ORACL 容器里已导入数据,欲迁移到已机器(192.168.1.114), 使用仓库上传方式, 导出的镜像太大,因此可以使用docker save 和docker load方式迁移
步骤: 甲机器:


[root@CentOS8 ~]# docker commit oracle11g  md
[root@CentOS8 ~]# docker images
REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
md                                                     latest              e76cf1687e46        11 seconds ago      7.83GB
[root@CentOS8 home]# docker save md -o /md.tar
[root@CentOS8 home]#  scp /home/md.tar root@192.168.1.114:/
The authenticity of host '192.168.1.114 (192.168.1.114)' can't be established.
ECDSA key fingerprint is SHA256:7yIPWkhWBZbWotM7k1T3M3vXHcDjRimyZuoIGYU/sW4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.114' (ECDSA) to the list of known hosts.
root@192.168.1.114's password:
md.tar                                          1%  148MB  10.5MB/s   11:41 ETA
md.tar                                          4%  345MB  10.7MB/s   11:10 ETA
md.tar                                         27% 2038MB  11.4MB/s   08:02 ETA
md.tar                                        100% 7533MB  10.8MB/s   11:35

已机器:


[root@SmartByDevServer ~]# docker load -i /md.tar
bab207619a1b: Loading layer  6.912GB/6.912GB
5f70bf18a086: Loading layer  1.024kB/1.024kB
be5668ce5ec1: Loading layer  904.7kB/904.7kB
082cf08b5c55: Loading layer  985.2MB/985.2MB
Loaded image: md:latest

[root@SmartByDevServer ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
md                  latest              e76cf1687e46        3 days ago          7.83GB
[root@SmartByDevServer ~]# docker run -d  --name docare   -p 1521:1521 --restart=always   md
a1a53cf0525dec9e7282f4931718f9c42066a0b2037a5dfb6627270cd0a6d018
 

如果docker run 时报错:


 [root@SmartByDevServer ~]# docker run -d  --name docare   -p 1521:1521   md
9ebde2c8c91f59b835eff14613da122d8cebc5b1f7593ff14c161c52db7299d6
docker: Error response from daemon: driver failed programming external connectivity on endpoint docare (eb90e740c1ace4b521738bd5e6c1e632387412bbea2a80bf7b367021a49fc4eb):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 1521 -j DNAT --to-destination 172.17.0.6:1521 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1)).


可以重启下docker服务即可:


[root@SmartByDevServer ~]# systemctl restart docker

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐