盛年不重来,一日难再晨,及时当勉励,岁月不待人。这篇文章主要讲述Docker镜像管理相关的知识,希望能为你提供帮助。
获取docker busybox镜像
[root@harbor < sub> ]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
5cc84ad355aa: Pull complete
Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest
[root@harbor < /sub> ]# docker images
REPOSITORYTAGIMAGE IDCREATEDSIZE
busyboxlatestbeae173ccac63 months ago1.24MB
nginxlatest605c77e624dd3 months ago141MB
显示完整的docker镜像ID,--no-trunc参数[root@harbor ~]# docker images --no-trunc
文章图片
查看当前docker镜像
[root@harbor ~]# docker images
REPOSITORYTAGIMAGE IDCREATEDSIZE
redisv107d6e5a00daa2 weeks ago109MB
nginxlatest605c77e624dd3 months ago141MB
redislatest7614ae9453d13 months ago113MB
centos7eeb6ee3f44bd7 months ago204MB
centoslatest5d0da3dc97647 months ago231MB
docker镜像打tag【Docker镜像管理】[root@harbor ~]# docker tag nginx:latest nginx:v1
文章图片
批量删除docker images第一种方法:
[root@harbor < sub> ]# docker images
REPOSITORYTAGIMAGE IDCREATEDSIZE
nginxlatet605c77e624dd3 months ago141MB
redislatest7614ae9453d13 months ago113MB
centos7eeb6ee3f44bd6 months ago204MB
[root@harbor < /sub> ]# docker images -q
605c77e624dd
7614ae9453d1
eeb6ee3f44bd
[root@harbor ~]# docker rmi $(docker images -q)
Untagged: nginx:latest
Untagged: nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Deleted: sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
Deleted: sha256:b625d8e29573fa369e799ca7c5df8b7a902126d2b7cbeb390af59e4b9e1210c5
Deleted: sha256:7850d382fb05e393e211067c5ca0aada2111fcbe550a90fed04d1c634bd31a14
Deleted: sha256:02b80ac2055edd757a996c3d554e6a8906fd3521e14d1227440afd5163a5f1c4
Deleted: sha256:b92aa5824592ecb46e6d169f8e694a99150ccef01a2aabea7b9c02356cdabe7c
Deleted: sha256:780238f18c540007376dd5e904f583896a69fe620876cabc06977a3af4ba4fb5
Untagged: redis:latest
Untagged: redis@sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339
Deleted: sha256:7614ae9453d1d87e740a2056257a6de7135c84037c367e1fffa92ae922784631
Deleted: sha256:49c70179bc923a7d48583d58e2b6c21bde1787edf42ed1f8de9e9b96e2e88e65
Deleted: sha256:396e06df5d1120368a7a8a4fd1e5467cdc2dd4083660890df078c654596ddc1c
Deleted: sha256:434d118df2e9edb51238f6ba46e9efdfa21be68e88f54787531aa39a720a0740
Deleted: sha256:2047f09c412ff06f4e2ee8a25d105055e714d99000711e27a55072e640796294
Deleted: sha256:13d71c9ccb39b206211dd1900d06aa1984b0f5ab8abaa628c70b3eb733303a65
Deleted: sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f
Untagged: centos:7
Untagged: centos@sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9
Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
第二种方法:
命令 docker image prune -a
[root@harbor < sub> ]# docker images
REPOSITORYTAGIMAGE IDCREATEDSIZE
redisv107d6e5a00daa2 weeks ago109MB
nginxlatest605c77e624dd3 months ago141MB
redislatest7614ae9453d13 months ago113MB
centos7eeb6ee3f44bd7 months ago204MB
centoslatest5d0da3dc97647 months ago231MB
[root@harbor < /sub> ]# docker ps
CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
03859aec2881nginx:latest"/docker-entrypoint.…"3 minutes agoUp 3 minutes80/tcpnginx
[root@harbor ~]# 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
Deleted Images:
untagged: centos:7
untagged: centos@sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9
deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
untagged: redis:v1
deleted: sha256:07d6e5a00daa386ed5117d7bf7751f74b46f5831aea69036580cd509bb6781e7
deleted: sha256:7c4045019efba50b56d30912599164ec3e5422537e152f01d08b3e3556b86919
untagged: centos:latest
untagged: centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
deleted: sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6
deleted: sha256:74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59
untagged: redis:latest
untagged: redis@sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339
deleted: sha256:7614ae9453d1d87e740a2056257a6de7135c84037c367e1fffa92ae922784631
deleted: sha256:49c70179bc923a7d48583d58e2b6c21bde1787edf42ed1f8de9e9b96e2e88e65
deleted: sha256:396e06df5d1120368a7a8a4fd1e5467cdc2dd4083660890df078c654596ddc1c
deleted: sha256:434d118df2e9edb51238f6ba46e9efdfa21be68e88f54787531aa39a720a0740
deleted: sha256:2047f09c412ff06f4e2ee8a25d105055e714d99000711e27a55072e640796294
deleted: sha256:13d71c9ccb39b206211dd1900d06aa1984b0f5ab8abaa628c70b3eb733303a65
推荐阅读
- Ansible自动化工具的实践
- Win10基础 路径 存放系统壁纸的文件夹
- 使用Redis解决秒杀业务问题分析与解决方案
- pg快速入门--体系结构
- Ansible使用playbook批量安装Nginx
- 电池管理系统你了解多少()
- CentOS 文件压缩命令
- 路由基础之访问控制列表
- 云迁移之5R方法优秀实践总结