Docker镜像管理

Docker镜像管理

1.1获取镜像

镜像拉取

docker search centos    //搜索镜像
docker pull centos:6.9   //拉取centos6.9镜像
docker pull centos:7.5.1804  //拉取centos7.5.1804镜像
docker pull nginx          //拉取nginx镜像

1.2 镜像查看

命令:docker image ls

例:

[root@localhost ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              daee903b4e43        7 days ago          133MB
centos              7.5.1804            cf49811e3cdb        20 months ago       200MB

注:
标识镜像唯一性的方法:
(1)REPOSITORY:TAG

例:centos:7.5.1804 

(2)IMAGE ID (sha256:64位的号码,默认只截取12位)

例:82f3b5f3c58    

1.3 镜像详细信息查看

命令:docker image inspect    (REPOSITORY:TAG  or  IMAGE ID )

例:

[root@localhost ~]# docker image inspect nginx:latest

例:

[root@localhost ~]# docker image inspect daee903b4e43

1.4 只查看镜像ID

命令:docker image ls -q

例:

[root@localhost ~]# docker image ls -q
daee903b4e43
2199b8eb8390
cf49811e3cdb

1.5 镜像的导入和导出

导出

命令:docker image save IMAGE ID  > 导出的文件

例:
将nginx镜像导出到 /tmp/nginx.tar.gz

[root@localhost ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              daee903b4e43        7 days ago          133MB
centos              6.9                 2199b8eb8390        20 months ago       195MB
centos              7.5.1804            cf49811e3cdb        20 months ago       200MB
[root@localhost ~]# docker image save daee903b4e43 > /tmp/nginx.tar.gz

导入

命令:docker image load -i 导入的文件

例:将上面导出的镜像导入

[root@localhost ~]# docker image load -i /tmp/nginx.tar.gz 
f5600c6330da: Loading layer [==================================================>]  72.52MB/72.52MB
32048dd980c7: Loading layer [==================================================>]  64.54MB/64.54MB
e3a971c30b12: Loading layer [==================================================>]  3.072kB/3.072kB
5887d03dfc3d: Loading layer [==================================================>]  4.096kB/4.096kB
b9e73ac5343e: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image ID: sha256:daee903b4e436178418e41d8dc223b73632144847e5fe81d061296e667f16ef2
导入之后查看无标签
[root@localhost ~]# docker image ls -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              daee903b4e43        7 days ago          133MB
centos              6.9                 2199b8eb8390        20 months ago       195MB
centos              7.5.1804            cf49811e3cdb        20 months ago       200MB
手动打标签
[root@localhost ~]# docker image tag daee903b4e43 nginx:latest
再次查看
[root@localhost ~]# docker image ls -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              daee903b4e43        7 days ago          133MB
centos              6.9                 2199b8eb8390        20 months ago       195MB
centos              7.5.1804            cf49811e3cdb        20 months ago       200MB


1.6 镜像的删除

删除单个镜像:

命令:docker image rm -f   IMAGE ID 
例:[root@localhost ~]# docker image rm -f daee903b4e43

删除全部镜像:

命令:docker image rm -f `docker image ls -q`

慎用!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值