一、打包传输
1.打包
[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker save -o centos.tar centos:latest
[root@localhost ~]# ls
anaconda-ks.cfg centos.tar
2.传输
[root@localhost ~]# scp centos.tar root@192.168.1.100:/root
3.删除镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 2 years ago 231MB
[root@localhost ~]# docker start c0 //启动容器
c0
[root@localhost ~]# docker attach c0 //进入容器
[root@207ca7680ecc /]# exit
exit
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]# docker ps --all //查看全部
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
207ca7680ecc centos:latest "/bin/bash" 20 hours ago Exited (0) 4 seconds ago c0
[root@localhost ~]# docker rmi centos:latest //这里看到没有删掉,因为有容器正在使用
Error response from daemon: conflict: unable to remove repository reference "centos:latest" (must force) - container 207ca7680ecc is using its referenced image 5d0da3dc9764
[root@localhost ~]# docker rm c0 //删除容器
c0
[root@localhost ~]# docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]# docker rmi centos:latest //成功删除
Untagged: centos:latest
Untagged: centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Deleted: sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6
Deleted: sha256:74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59
[root@local