首页 > 其他分享 >docker----镜像(二)

docker----镜像(二)

时间:2024-03-06 15:46:18浏览次数:22  
标签:ago MB -- ---- ubuntu 镜像 docker latest

镜像查看

查看镜像

[root@hmm-docker ~]# docker images 
REPOSITORY#镜像仓库   TAG #标签      IMAGE ID#镜像id       CREATED #创建时间       SIZE#大小
my-hello     latest    6d0c09473a66   20 hours ago   861kB
ubuntu       latest    3db8720ecbf5   3 weeks ago    77.9MB
httpd        latest    2776f4da9d55   7 weeks ago    167MB
ubuntu       18.04     f9a80a55f492   9 months ago   63.2MB
centos       latest    5d0da3dc9764   2 years ago    231MB
ubuntu       14.04     13b66b487594   2 years ago    197MB

查看镜像的摘要值

[root@hqs-docker ~]# docker images ubuntu  --digests
REPOSITORY   TAG       DIGEST                                                                    IMAGE ID       CREATED        SIZE
ubuntu       latest    sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da   3db8720ecbf5   3 weeks ago    77.9MB
ubuntu       18.04     sha256:152dc042452c496007f07ca9127571cb9c29697f42acbfad72324b2bb2e43c98   f9a80a55f492   9 months ago   63.2MB
ubuntu       14.04     <none>                                                                    13b66b487594   2 years ago    197MB

查看镜像完整id

[root@hqs-docker ~]# docker images ubuntu  --no-trunc
REPOSITORY   TAG       IMAGE ID                                                                  CREATED        SIZE
ubuntu       latest    sha256:3db8720ecbf5f5927d409cc61f9b4f7ffe23283917caaa992f847c4d83338cc1   3 weeks ago    77.9MB
ubuntu       18.04     sha256:f9a80a55f492e823bf5d51f1bd5f87ea3eed1cb31788686aa99a2fb61a27af6a   9 months ago   63.2MB
ubuntu       14.04     sha256:13b66b487594a1f2b75396013bc05d29d9f527852d96c5577cc4f187559875d0   2 years ago    197MB

自定义镜像模板输出

  • 输出json模式
[root@hqs-docker ~]# docker images centos  --format json
{"Containers":"N/A","CreatedAt":"2021-09-16 02:20:05 +0800 CST","CreatedSince":"2 years ago","Digest":"\u003cnone\u003e","ID":"5d0da3dc9764","Repository":"centos","SharedSize":"N/A","Size":"231MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"231.3MB"}
  • 自定义输出模板
[root@hqs-docker ~]# docker images centos  --format "{{.Repository}}---{{.Tag}}"
centos---latest
[root@hqs-docker ~]# docker images  --format "{{.Repository}}--{{.Tag}}--{{.Size}}"
my-hello--latest--861kB
ubuntu--latest--77.9MB
httpd--latest--167MB
ubuntu--18.04--63.2MB
centos--latest--231MB
ubuntu--14.04--197MB
[root@hqs-docker ~]# docker images  --format "{{.Repository}}:{{.Tag}}:{{.Size}}"
my-hello:latest:861kB
ubuntu:latest:77.9MB
httpd:latest:167MB
ubuntu:18.04:63.2MB
centos:latest:231MB
ubuntu:14.04:197MB****

只显示镜像id,方便批量操作

[root@hqs-docker ~]# docker images -q
6d0c09473a66
3db8720ecbf5
2776f4da9d55
f9a80a55f492
5d0da3dc9764
13b66b487594

镜像条件筛选

  • dangling:标识为空的镜像,值有true和false两种
[root@hmm-docker ~]# docker image ls  --filter dangling=true
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@hmm-docker ~]# docker image ls  --filter dangling=false
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
my-hello     latest    6d0c09473a66   20 hours ago   861kB
ubuntu       latest    3db8720ecbf5   3 weeks ago    77.9MB
httpd        latest    2776f4da9d55   7 weeks ago    167MB
ubuntu       18.04     f9a80a55f492   9 months ago   63.2MB
centos       latest    5d0da3dc9764   2 years ago    231MB
ubuntu       14.04     13b66b487594   2 years ago    197MB
  • before:根据时间过滤,某个镜像构建之前的镜像
[root@hmm-docker ~]# docker image ls --filter before=6d0c09473a66
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
ubuntu       latest    3db8720ecbf5   3 weeks ago    77.9MB
httpd        latest    2776f4da9d55   7 weeks ago    167MB
ubuntu       18.04     f9a80a55f492   9 months ago   63.2MB
centos       latest    5d0da3dc9764   2 years ago    231MB
ubuntu       14.04     13b66b487594   2 years ago    197MB
[root@hmm-docker ~]# docker image ls --filter before=ubuntu
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
httpd        latest    2776f4da9d55   7 weeks ago    167MB
ubuntu       18.04     f9a80a55f492   9 months ago   63.2MB
centos       latest    5d0da3dc9764   2 years ago    231MB
ubuntu       14.04     13b66b487594   2 years ago    197MB
[root@hmm-docker ~]# docker image ls --filter before=ubuntu:18.04
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
centos       latest    5d0da3dc9764   2 years ago   231MB
ubuntu       14.04     13b66b487594   2 years ago   197MB
  • since:根据时间过滤,某个镜像构建之后的镜像
[root@hmm-docker ~]# docker image ls --filter since=ubuntu:18.04
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
my-hello     latest    6d0c09473a66   20 hours ago   861kB
ubuntu       latest    3db8720ecbf5   3 weeks ago    77.9MB
httpd        latest    2776f4da9d55   7 weeks ago    167MB
  • label:根据标签过滤
[root@hmm-docker docker-hello]# docker images --filter label=name
REPOSITORY     TAG       IMAGE ID       CREATED        SIZE
hello-label2   latest    c0dd54a49365   20 hours ago   861kB
hello-label    latest    7bb17936061a   20 hours ago   861kB
hello-label3   latest    fef21c202867   20 hours ago   861kB

批量删除镜像

  • 通过shell命令替换dockeriamges命令可以解决镜像的批量操作
docker images -f label=name -q
docker image rm $(docker images -f label=name -q)
  • 如果要删除本地所有的镜像通常会如下操作
docker rmi $(docker images -q)

标签:ago,MB,--,----,ubuntu,镜像,docker,latest
From: https://www.cnblogs.com/humlogs/p/18056762

相关文章

  • CF1935E Distance Learning Courses in MAC
    CF1935EDistanceLearningCoursesinMAC题目大意给定\(n\)个变量\(z_i\in[x_i,y_i]\),你可以在范围内任意指定\(z_i\)的值。\(q\)次查询,每次查询给定区间\([l_i,r_i]\),求用这些变量得到的二进制或最大值。思路选择\(z\in[x,y]\),贡献分为两部分(1)\([x,y]\)的......
  • CMS垃圾收集器
    CMSGC的英文名为:“MostlyConcurrentMarkandSweepGarbageCollector”(最大-并发-标记-清除-垃圾收集器)。作用范围:老年代算法:并发标记清除算法。启用参数:-XX:+UseConMarkSweepGC默认回收线程数:(处理器核心数量+3)/4Java9之后使用CMS垃圾收集器后,默认年轻代就为ParNew收......
  • 洛谷题单指南-搜索-P1605 迷宫
    原题链接:https://www.luogu.com.cn/problem/P1605题意解读:从起点走到终点的方案数,DFS可遍历所有情况。解题思路:在DFS过程中,有两种标记墙:不能访问已访问过的,不能重复访问定义数组inta[N][N]表示迷宫,1是墙或者已访问过的,0是可以通过的。100分代码:#include<bits/stdc++.h>......
  • ora_rowscn 行为观察
    开启行级别改变记录createtablefoo3(aint)rowdependencies;插入数据insertintofoo3values(1);insertintofoo3values(2);--结果为nullselectora_rowscnfromfoo3;提交commit;--两行记录的scn相同selectora_rowscnfromfoo3;再插入in......
  • 进程退出:SIGINT、SIGTERM和SIGKILL区别
    普通用户使用的信号:信号值      符号      行为2          SIGINT    进程终端,CTRL+C9          SIGKILL   强制终端15         SIGTEM    请求中断20         SIGTOP    停止(挂起)进程CRTL+DSIGINT、SI......
  • Maven安装本地的jar包和创建带模板的自定义项目
    Maven安装本地的jar包如果没配置Maven的环境变量,需要先CD到maven的安装目录,因为没配置环境变量,mvn命令是无法在maven安装目录以外的目录运行。cdC:\Maven\apache-maven-3.6.3\bin然后执行下面命令格式如下:mvninstall:install-file//固定格式,maven的语法-Dfile=ali......
  • 解决datepicker设置限定日期范围后 选中节点日期不生效
    问题描述:项目要求设定日期限定范围,如2023-04-01至2024-03-01,其它不可选 但每当我选择的月份包含4月或次年3月时,即使选中日期,弹窗也不消失经过我机智过人的大脑”短暂“思考后,发现当我设定限定范围时,是这样设置的returntime.getTime()<newDate("2023-04-01").getTime()......
  • K3s - 轻量级 Kubernetes
    一、k3s介绍1.1、什么是k3s中文网站:http://docs.rancher.cn/docs/k3s/quick-start/_index/k3s是经过CNCF认证的由Rancher公司开发维护的一个轻量级的Kubernetes发行版,内核机制还是和k8s一样,但是剔除了很多外部依赖以及K8s的alpha、beta特性,同时改变了部署方式和运行方......
  • C++的4种强制类型
    C++提供了4种强制类型转换的语法:静态转换(static_cast)static_cast是用于在没有二义性的前提下进行基本数据类型转换的一种转换方式。它只能用于具有相关性的数据类型之间的转换,如将int类型转换为double类型。如果进行无关的数据类型之间的转换,编译器将报错。用途:通常用......
  • (面试题1)看程序写结果(先判断有没有问题,如果没有,写出结果)
    面试题:1:看程序写结果(先判断有没有问题,如果没有,写出结果)packagecom.shujia.面试题;classFu{publicvoidshow(){System.out.println("fushow");}}classZiextendsFu{publicvoidshow(){System.out.println("zishow"......