Docker镜像管理常用

docker镜像管理命令

镜像管理命令说明
docker images查看本机镜像
docker search 镜像名称从官方仓库查找镜像
docker pull 镜像名称:标签下载镜像
docker push 镜像名称:标签上传镜像
docker save -o 备份镜像名称.tar 镜像名称:标签备份镜像为tar包
docker load -i 备份镜像名称导入备份的镜像文件
docker rmi 镜像名称:标签删除镜像(必须先删除该镜像启动的所有容器)
docker history 镜像名称:标签查看镜像的制作历史
docker inspect 镜像名称:标签查看镜像的详细信息
docker tag 镜像名称:标签 新的镜像名称:新的标签创建新的镜像名称和标签

在这里插入图片描述


查看镜像的构建步骤

https://blog.csdn.net/omaidb/article/details/122044116


查看镜像的详细信息

# 查看镜像的详细信息
docker inspect 镜像名

导出镜像

# 将ubuntu:latest镜像导出到当前目录
docker save ubuntu:latest -o ubuntu-latest.tar

导入镜像

# 将ubuntu-latest.tar镜像导入
docker loda -i ~/ubuntu-latest.tar

# 查看镜像
docker images

修改镜像tag

# 查看本地镜像
[rhel8 root ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    feb5d9fea6a5   5 weeks ago   13.3kB

# 修改镜像
## docker tag 镜像名称:标签 新的镜像名称:新的标签	
[rhel8 root ~]# docker tag hello-world:latest hello-world:test
# 查看镜像
[rhel8 root ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    feb5d9fea6a5   5 weeks ago   13.3kB
hello-world   test      feb5d9fea6a5   5 weeks ago   13.3kB

清理损坏镜像

# 清理损坏的镜像
[c8 root ~]# docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y

清理所有未使用镜像

# 清理所有未使用镜像
docker image prune -a

在这里插入图片描述


清理未使用容器/数据卷/镜像

# 删除所有退出状态的容器(包括非docker容器)
docker container prune

# 删除未被使用的数据卷
docker volume prune

# 删除 dangling 或所有未被使用的镜像
docker image prune

在这里插入图片描述


清理所有未使用的资源

删除已停止的容器dangling 镜像、未被容器引用的 network 和构建过程中的 cache

参考: https://www.cnblogs.com/sparkdev/p/9177283.html

# 清理所有未使用的资源(不清除存储卷)
docker system prune --all

# 清理所有未使用的资源(清理未使用的存储卷)
docker system prune --all --force --volumes

显示docker磁盘使用情况

参考: 显示docker磁盘使用情况

# 显示所用数据的摘要
docker system df

# 详细试图
docker system df -v

在这里插入图片描述


Docker学习笔记

花了很长时间总结的Docker学习笔记,
想要这个docker学习笔记的.xmind文件可以在下方留言,我把笔记传上来。

在本博客学习docker,配合精心制作的docker笔记,学习效果更佳
https://download.csdn.net/download/omaidb/12581323

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

识途老码

赞赏是第一生产力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值