05-docker 镜像导入导出
1.拉取镜像,默认是从官网docker拉取
[root@docker03 ~]# docker pull centos Using default tag: latest latest: Pulling from library/centos 5e35d10a3eba: Pull complete Digest: sha256:dcbc4e5e7052ea2306eed59563da1fec09196f2ecacbe042acbdcd2b44b05270 Status: Downloaded newer image for centos:latest
2.查看本地镜像
[root@docker03 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 2d194b392dd1 2 weeks ago 195MB hello-world latest f2a91732366c 3 months ago 1.85kB
3.镜像导出及导入
# 导出容器镜像 [root@docker03 ~]# docker save centos > /opt/centos.tar.gz [root@docker03 ~]# # 查看容器镜像 [root@docker03 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 2d194b392dd1 2 weeks ago 195MB hello-world latest f2a91732366c 3 months ago 1.85kB # 删除容器镜像 [root@docker03 ~]# docker rmi centos Untagged: centos:latest Untagged: centos@sha256:dcbc4e5e7052ea2306eed59563da1fec09196f2ecacbe042acbdcd2b44b05270 Deleted: sha256:2d194b392dd16955847a14f969b2dd319251471ffa6356be6d8f16c5bf53db9b Deleted: sha256:b03095563b7956c62ae5a6d20e5959a950e3b1a96d4404c00b7da7393847494a # 查看已经删除了centos容器镜像 [root@docker03 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest f2a91732366c 3 months ago 1.85kB # 导入centos容器镜像(2种方式) [root@docker03 ~]# docker load < /opt/centos.tar.gz [root@docker03 ~]# docker load --input /opt/centos.tar.gz b03095563b79: Loading layer [==================================================>] 204MB/204MB Loaded image: centos:latest # centos容器镜像导入了 [root@docker03 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 2d194b392dd1 2 weeks ago 195MB hello-world latest f2a91732366c 3 months ago 1.85kB

浙公网安备 33010602011771号