docker 镜像(images)

搜索镜像

语法:

docker search [OPTIONS] TERM

搜索出错看这个:

记录 docker search || pull被拒绝的解决_W_Y_1139的博客-CSDN博客icon-default.png?t=M276https://blog.csdn.net/qq_41144591/article/details/123923484

正常搜索:

[root@localhost ~]# docker search helloword
NAME                               DESCRIPTION                      STARS               OFFICIAL            AUTOMATED
chenghuizhang/helloword                                             1                                       
shettysachin80/hellowordquery                                       1                                       
amritpalkaur/helloword             automate build of java program   0                                       [OK]
iiccqq12345/helloword              helloword                        0                                       
awreneau/helloword                                                  0                                       
gulj/helloword                     helloword                        0                                                                          

搜索点赞>=1的:

[root@localhost ~]# docker search helloword -s 1
Flag --stars has been deprecated, use --filter=stars=3 instead
NAME                            DESCRIPTION         STARS               OFFICIAL            AUTOMATED
chenghuizhang/helloword                             1                                       
shettysachin80/hellowordquery  

显示完整的信息:

[root@localhost ~]# docker search -s 1 --no-trunc nginx
Flag --stars has been deprecated, use --filter=stars=3 instead
NAME                                              DESCRIPTION                                                                                       STARS               OFFICIAL            AUTOMATED
nginx                                             Official build of Nginx.                                                                          16559               [OK]                
bitnami/nginx                                     Bitnami nginx Docker Image                                                                        120                                     [OK]
ubuntu/nginx                                      Nginx, a high-performance reverse proxy & web server. Long-term tracks maintained by Canonical.   38                                      
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Controller                                                 17                                      [OK]
rancher/nginx-ingress-controller                                                                                                                    10                                      
ibmcom/nginx-ingress-controller                   Docker Image for IBM Cloud Private-CE (Community Edition) AMD64 ingress controller component      4                                       
bitnami/nginx-ldap-auth-daemon                                                                                                                      3                                       
bitnami/nginx-exporter                                                                                                                              2                                       
rancher/nginx-ingress-controller-defaultbackend                                                                                                     2                                       
circleci/nginx                                    This image is for internal use                                                                    2                                       
vmware/nginx                                                                                                                                        2                                       
rancher/nginx                                                                                                                                       1                                       
vmware/nginx-photon                                                                                                                                 1                                       
bitnami/nginx-intel 

格式化输出:

[root@localhost ~]# docker search --format "{{.Name}}" nginx
nginx
bitnami/nginx
ubuntu/nginx
bitnami/nginx-ingress-controller
rancher/nginx-ingress-controller
ibmcom/nginx-ingress-controller
bitnami/nginx-ldap-auth-daemon
bitnami/nginx-exporter
circleci/nginx

字段说明:

NAME:镜像的名字
DESCRIPTION:镜像的描述说明
STARS:标星个数(点赞)
STARS:是否官方
AUTOMATED:是否从 Dockerfile 自动构建

参数说明:

-s:显示收藏数不小于几颗星的镜像
--no-trunc:不截断输出,显示详情
-f:基于给定条件过滤输出;例输出收藏星数>=3:docker search -f stars=3 nginx
--format:格式化输出

镜像拉取pull

语法:

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

OPTIONS说明:

-a :拉取所有 tagged 镜像
--disable-content-trust :忽略镜像的校验,默认开启
--help:查看帮助

TAG标签说明 :默认不指定是拉取最新的(latest),pull不能看tag是哪个版本,要看就浏览器去dockerHub上看

查看镜像

 语法:

docker images [OPTIONS] [REPOSITORY[:TAG]]

 平常用的:

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              12766a6745ee        4 days ago          142MB
httpd               latest              118b6abfbf55        4 days ago          144MB
postgres            latest              1ee973e26c65        4 days ago          376MB

OPTIONS说明:

-a :列出本地所有的镜像(含中间映像层,默认情况下,过滤掉中间映像层);
--digests :显示镜像的摘要信息;
-f :显示满足条件的镜像;
--format :指定返回值的模板文件;
--no-trunc :显示完整的镜像信息;
-q :只显示镜像ID。

字段说明:

REPOSITORY:镜像
TAG:标签
IMAGE ID :镜像ID
CREATED:创建
SIZE:大小

删除镜像

注:如果一个镜像是另一个镜像的引用镜像,它是无法被删除的

语法:

docker rmi Image

单个删除:

[root@localhost ~]# docker rmi httpd
Untagged: httpd:latest
Untagged: httpd@sha256:e3c40b99ffa305c6e52346a6618b1fb47ea0568c999b26f8900cd26febab1160
Deleted: sha256:118b6abfbf555d6b42cec48383acfb4985ead4d1d6a67fbb5a0e78fafe615ce2
Deleted: sha256:8ac6f674480a75e0becb59b0b9771587a7656be5a03bd7d7e200062e8d4e958e
Deleted: sha256:49506e75501a6587fde47b46be5bbab8df2ceac7b6121db9599e8b608365020b
Deleted: sha256:b6ac0b8312fa2b5dcb5fd81dc1b126682a8e52fa01ed95dad6e084c0042992a6
Deleted: sha256:aacb3062d128718f5211d70c46d8696e4fb716dc9eb9f7b8be6d441584eedca2

条件删除多个:

注:括号里查出来的就是你要删除的

docker rmi -f $(docker images -a -q)
或者:
docker images -a -q | xargs docker rmi

删除所有:

docker rmi $(docker images -a -q)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值