惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

PCI Perspectives
PCI Perspectives
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
V
Visual Studio Blog
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security Affairs
S
SegmentFault 最新的问题
C
Cisco Blogs
博客园 - 聂微东
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
量子位
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Latest
Security Latest
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog

Liu Zijian's Blog | 一个技术博客

使用Certbot自动续签HTTPS证书 使用Filebeat采集Nginx日志到ES Python的协程 Python中的异常 Python中的类和对象 Python的函数 Python的数据结构,推导式、迭代器和生成器 Spring AI集成多模态模型 LangChain4j多模态 LangChain Tools工具使用 Python中的模块和包 Python全局环境和虚拟环境(venv) LangChain Prompt提示词工程 LangChain4j Tools工具使用 基于Dify搭建AI智能体应用 LangChain4j RAG检索增强生成 Spring AI实现MCP Server Spring AI集成MCP Client LangChain4j Prompt提示词工程 Spring AI使用知识库增强对话功能 Spring AI实现一个智能客服 Spring AI实现一个简单的对话机器人 实现MinIO数据的每日备份 自己实现一个DNS服务 简单理解AI智能体 大模型和大模型应用 LangChain开篇 LangChain4j开篇 一个解析Excel2007的POI工具类 DataPermissionInterceptor源码解读 TenantLineInnerInterceptor源码解读 BaseMultiTableInnerInterceptor源码解读 Spring AI开篇 SQL解析工具JSQLParser 芋道源码解读之多租户 芋道源码解读之数据权限 芋道源码解读开篇 Java实现将数据导出为Word文档 OA系统的天数该怎样计算 安装MySQL8 安装MySQL5.7 RockyLinux9环境下编译MySQL8 MySQL字符集及底层原理 Java实现LDAP登录 Docker Compose IPv4和IPv6 使用虚拟机安装一个K8s集群 使用GraalVM原生编译打包SpringBoot工程 Nginx防止目录穿越 Java线程的状态 Nginx防盗链设置 使用python将excel表格转换为SQL INSERT Redis的公共操作命令 Redis数据结构之Bitfleid Redis数据结构之Bitmap Redis数据结构之GEO Redis数据结构之Hash Redis数据结构之HyperLogLog Redis数据结构之List Redis数据结构之Set Redis数据结构之Stream Redis数据结构之String Redis数据结构之ZSet 使用python压缩图片 利用Python实现Hexo站点的持续集成 Nginx设置HTTPS监听 firewalld防火墙工具的使用 Linux信号(signal)机制 MySQL5.7x 主从复制 用IP自签发一个HTTPS证书 基于Hexo实现一个静态的个人博客 RockyLinux9环境下编译MySQL5.7 Docker离线安装 MySQL数据定义语言 Docker与联合文件系统 Docker的网络 Docker的镜像操作 MySQL存储过程 MyBatis-Plus开篇 MySQL变量 MySQL视图 MySQL事务 MySQL插入修改和删除 MySQL查询 MySQL系统命令 Docker的容器操作 Docker的安装和配置 Docker容器数据卷 浅谈OAuth2.0授权原理 JVM开篇 浅谈Linux(Unix)的I/O模型 一个通用的CloseableHttpClient工厂类 JUC可重入锁ReentrantLock JUC读写锁ReadWriteLock Java的单例 Java泛型 Java8的新特性 最近最少使用算法(LRU) MySQL函数 SpringBoot配置和启动
Docker的镜像操作
Liu Zijian · 2023-11-17 · via Liu Zijian's Blog | 一个技术博客

从镜像仓库中拉取镜像时,需要科学上网访问DockerHub

1.镜像

镜像是一种轻量级,可执行的独立软件包,用来打包软件运行环境和基于运行环境开发的软件,它包含运行某个软件所需的所有内容,包括代码,运行时,库,环境变量和配置文件。

2.常见镜像操作

1.列出本地所有镜像

docker images
[root@localhost ~]# docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
redis                    7.0.11              4695a05c473a        16 months ago       130MB
nacos/nacos-server       v2.2.3              17169ab516b8        17 months ago       814MB
sonatype/nexus3          3.54.1              9dcc5d2a8db6        18 months ago       550MB
mysql                    8.0.31              c2c2eba5ae85        2 years ago         535MB
gitlab/gitlab-ce         latest              46cd6954564a        2 years ago         2.36GB
adolfintel/speedtest     latest              1bb6f28b9d23        2 years ago         439MB
prom/prometheus          latest              a3d385fc29f9        2 years ago         201MB
grafana/grafana          latest              9b957e098315        2 years ago         275MB
portainer/portainer-ce   latest              0df02179156a        2 years ago         273MB
mysql                    5.7                 db39680b63ac        4 years ago         437MB
kibana                   7.4.2               230d3ded1abc        5 years ago         1.1GB
elasticsearch            7.4.2               b1179d41a7b4        5 years ago         855MB

各列含义

  • REPOSITORY 镜像的仓库源
  • TAG 镜像的标签
  • IMAGE ID 镜像的ID
  • CREATED 镜像的创建时间
  • SIZE 镜像大小

2.列出本地所有镜像(含中间镜像层)

docker images -a 
[root@localhost ~]# docker images -a
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
redis                    7.0.11              4695a05c473a        16 months ago       130MB
nacos/nacos-server       v2.2.3              17169ab516b8        17 months ago       814MB
sonatype/nexus3          3.54.1              9dcc5d2a8db6        18 months ago       550MB
mysql                    8.0.31              c2c2eba5ae85        2 years ago         535MB
gitlab/gitlab-ce         latest              46cd6954564a        2 years ago         2.36GB
adolfintel/speedtest     latest              1bb6f28b9d23        2 years ago         439MB
prom/prometheus          latest              a3d385fc29f9        2 years ago         201MB
grafana/grafana          latest              9b957e098315        2 years ago         275MB
portainer/portainer-ce   latest              0df02179156a        2 years ago         273MB
mysql                    5.7                 db39680b63ac        4 years ago         437MB
kibana                   7.4.2               230d3ded1abc        5 years ago         1.1GB
elasticsearch            7.4.2               b1179d41a7b4        5 years ago         855MB

3.显示所有镜像ID

docker images -q
[root@localhost ~]# docker images -q
4695a05c473a
17169ab516b8
9dcc5d2a8db6
c2c2eba5ae85
46cd6954564a
1bb6f28b9d23
a3d385fc29f9
9b957e098315
0df02179156a
db39680b63ac
230d3ded1abc
b1179d41a7b4

4.摘要信息

docker images --digests 
[root@localhost ~]# docker images --digests
REPOSITORY               TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
redis                    7.0.11              sha256:1008c73f08e9f913868e2fa2e843212b62ea5bf3c66435d87bc7a6207bc0f1b4   4695a05c473a        16 months ago       130MB
nacos/nacos-server       v2.2.3              sha256:cd7aa1cda9c639fbf6791d4bfea11a2596be18cc0d7f86f62ebd168076dd10c5   17169ab516b8        17 months ago       814MB
sonatype/nexus3          3.54.1              sha256:d1d3bd124102e98e2e2ab8aec865b7c5f2d34205e5487bac5e9cadb8b64363ae   9dcc5d2a8db6        18 months ago       550MB
mysql                    8.0.31              sha256:d4055451e7f42869e64089a60d1abc9e66eccde2910629f0dd666b53a5f230d8   c2c2eba5ae85        2 years ago         535MB
gitlab/gitlab-ce         latest              sha256:5a0b03f09ab2f2634ecc6bfeb41521d19329cf4c9bbf330227117c048e7b5163   46cd6954564a        2 years ago         2.36GB
adolfintel/speedtest     latest              sha256:9716783d60e87a25e916869a73f0d2ccdc9d579e19820df6c98ef58052aca9c4   1bb6f28b9d23        2 years ago         439MB
prom/prometheus          latest              sha256:cb9817249c346d6cfadebe383ed3b3cd4c540f623db40c4ca00da2ada45259bb   a3d385fc29f9        2 years ago         201MB
grafana/grafana          latest              sha256:18d94ae734accd66bccf22daed7bdb20c6b99aa0f2c687eea3ce4275fe275062   9b957e098315        2 years ago         275MB
portainer/portainer-ce   latest              sha256:4f126c5114b63e9d1bceb4b368944d14323329a9a0d4e7bb7eb53c9b7435d498   0df02179156a        2 years ago         273MB
mysql                    5.7                 sha256:b38555e593300df225daea22aeb104eed79fc80d2f064fde1e16e1804d00d0fc   db39680b63ac        4 years ago         437MB
kibana                   7.4.2               sha256:355f9c979dc9cdac3ff9a75a817b8b7660575e492bf7dbe796e705168f167efc   230d3ded1abc        5 years ago         1.1GB
elasticsearch            7.4.2               sha256:543bf7a3d61781bad337d31e6cc5895f16b55aed4da48f40c346352420927f74   b1179d41a7b4        5 years ago         855MB

5.不截取

docker images --no-trunc
[root@localhost ~]# docker images --no-trunc
REPOSITORY               TAG                 IMAGE ID                                                                  CREATED             SIZE
redis                    7.0.11              sha256:4695a05c473aa2db2dff0384abb06c2174832183ca0783d0a2720a922792add6   16 months ago       130MB
nacos/nacos-server       v2.2.3              sha256:17169ab516b8dcbd1b79448471545063f827bca0cec8054101970d9d8e9cbb55   17 months ago       814MB
sonatype/nexus3          3.54.1              sha256:9dcc5d2a8db635dab8c98eec3bd1a10ae7deabfa0a6e73f51087ba09b0972961   18 months ago       550MB
mysql                    8.0.31              sha256:c2c2eba5ae857a8ab9bffd11c5f15ed693dc65ac035948696f370f2895ae3062   2 years ago         535MB
gitlab/gitlab-ce         latest              sha256:46cd6954564a5a4ba6edd0cb19f6e0594d8a84c9d4a10a49f5f2caa485981fe8   2 years ago         2.36GB
adolfintel/speedtest     latest              sha256:1bb6f28b9d2386924b3d69790f59097680d0721afdb9b8f277201d314f8c583e   2 years ago         439MB
prom/prometheus          latest              sha256:a3d385fc29f926eed67f0d60ffaf72d199f3f9c24af5d55cd1802f2dc1dc9b4b   2 years ago         201MB
grafana/grafana          latest              sha256:9b957e098315598ae58c7a62bcc140ed086bbe619b38c31a52b21abbd5eb21e2   2 years ago         275MB
portainer/portainer-ce   latest              sha256:0df02179156afbf727443d0be50e8b9cdab8c044050691517539cea2e3ed01fd   2 years ago         273MB
mysql                    5.7                 sha256:db39680b63ac47a1d989da7b742f7b382af34d85a68214f8977bad59c05901a6   4 years ago         437MB
kibana                   7.4.2               sha256:230d3ded1abc1468536e41d80a9cc6a67908358c0e4ebf065c29b8ef0370ba4b   5 years ago         1.1GB
elasticsearch            7.4.2               sha256:b1179d41a7b42f921f8ea0c5fa319c8aac4a3083dd733494170428917007e55f   5 years ago         855MB

6.搜索镜像

docker search jenkins
[root@localhost ~]# docker search jenkins
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
jenkins                            DEPRECATED; use "jenkins/jenkins:lts" instead   5696                [OK]                
jenkins/jenkins                    The leading open source automation server       4049                                    
jenkins/jnlp-slave                 a Jenkins agent which can connect to Jenkins…   157                                     [OK]
jenkins/inbound-agent              This is an image for Jenkins agents using TC…   138                                     
jenkins/agent                      This is a base image, which provides the Jen…   71                                      
jenkins/ssh-agent                  Docker image for Jenkins agents connected ov…   60                                      
jenkins/slave                      base image for a Jenkins Agent, which includ…   49                                      [OK]
jenkins/ssh-slave                  A Jenkins slave using SSH to establish conne…   41                                      [OK]
jenkins/jnlp-agent-maven           A JNLP-based agent with Maven 3 built in        10                                      
jenkins/jnlp-agent-docker                                                          10                                      
jenkins/evergreen                  An automatically self-updating Jenkins distr…   5                                       
jenkins/pct                        Plugin Compat Tester - no longer published a…   5                                       [OK]
jenkins/jenkinsfile-runner         Jenkinsfile Runner packages                     3                                       
jenkins/jnlp-agent-python          A JNLP-based agent with Python built in         3                                       
jenkins/jnlp-agent-python3                                                         3                                       
jenkins/jenkins-experimental       Experimental images of Jenkins. These images…   3                                       [OK]
jenkins/jnlp-agent-coresdk                                                         2                                       
jenkins/jnlp-agent-alpine                                                          2                                       
jenkins/ath                        Jenkins Acceptance Test Harness                 1                                       [OK]
jenkins/remoting-kafka-agent       Remoting Kafka Agent                            1                                       [OK]
jenkins/core-pr-tester             Docker image for testing pull-requests sent …   1                                       
jenkins/jnlp-agent-node                                                            1                                       
jenkins/jnlp-agent-ruby                                                            1                                       
jenkins/core-changelog-generator   Tool for generating Jenkins core changelogs     1                                       
jenkins/custom-war-packager        Custom WAR Packager                             1                                       [OK]

7.搜索star数目不少于多少的镜像

docker search --filter=stars=3  jenkins
[root@localhost ~]# docker search --filter=stars=3  jenkins
NAME                           DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
jenkins                        DEPRECATED; use "jenkins/jenkins:lts" instead   5696                [OK]                
jenkins/jenkins                The leading open source automation server       4049                                    
jenkins/jnlp-slave             a Jenkins agent which can connect to Jenkins…   157                                     [OK]
jenkins/inbound-agent          This is an image for Jenkins agents using TC…   138                                     
jenkins/agent                  This is a base image, which provides the Jen…   71                                      
jenkins/ssh-agent              Docker image for Jenkins agents connected ov…   60                                      
jenkins/slave                  base image for a Jenkins Agent, which includ…   49                                      [OK]
jenkins/ssh-slave              A Jenkins slave using SSH to establish conne…   41                                      [OK]
jenkins/jnlp-agent-maven       A JNLP-based agent with Maven 3 built in        10                                      
jenkins/jnlp-agent-docker                                                      10                                      
jenkins/pct                    Plugin Compat Tester - no longer published a…   5                                       [OK]
jenkins/evergreen              An automatically self-updating Jenkins distr…   5                                       
jenkins/jnlp-agent-python      A JNLP-based agent with Python built in         3                                       
jenkins/jenkins-experimental   Experimental images of Jenkins. These images…   3                                       [OK]
jenkins/jenkinsfile-runner     Jenkinsfile Runner packages                     3                                       
jenkins/jnlp-agent-python3                                                     3                                       

8.只列出自动构建类型的镜像

docker search --filter=is-automated=true  jenkins
[root@localhost ~]# docker search --filter=is-automated=true  jenkins
NAME                           DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
jenkins/jnlp-slave             a Jenkins agent which can connect to Jenkins…   157                                     [OK]
jenkins/slave                  base image for a Jenkins Agent, which includ…   49                                      [OK]
jenkins/ssh-slave              A Jenkins slave using SSH to establish conne…   41                                      [OK]
jenkins/pct                    Plugin Compat Tester - no longer published a…   5                                       [OK]
jenkins/jenkins-experimental   Experimental images of Jenkins. These images…   3                                       [OK]
jenkins/ath                    Jenkins Acceptance Test Harness                 1                                       [OK]
jenkins/remoting-kafka-agent   Remoting Kafka Agent                            1                                       [OK]
jenkins/custom-war-packager    Custom WAR Packager                             1                                       [OK]

9.拉取镜像

从远程仓库拉取一个镜像,版本号不写默认是last

docker pull  名称:版本
[root@localhost ~]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
afad30e59d72: Pull complete 
918d361e6529: Pull complete 
cf4dd2a7e40b: Pull complete 
d152af7a0148: Pull complete 
a5d7958ebd69: Pull complete 
409b41a58ed4: Pull complete 
4f4fb700ef54: Pull complete 
9eabaa92f491: Pull complete 
Digest: sha256:2ade2b0a424a446601688adc36c4dc568dfe5198f75c99c93352c412186ba3c9
Status: Downloaded newer image for tomcat:latest

10.删除镜像

删除镜像

版本号不写默认是last

docker rmi  名称:版本
[root@localhost ~]# docker rmi tomcat
Untagged: tomcat:latest
Untagged: tomcat@sha256:2ade2b0a424a446601688adc36c4dc568dfe5198f75c99c93352c412186ba3c9
Deleted: sha256:f77539e7e45f7c6337c681589fe18ee6407640e4066c450fcfb8c6a4ba5575b2
Deleted: sha256:ec216f70111f7e403bf2dd00786888a33e31e0b7d40b7a6963c413312b916a72
Deleted: sha256:0269bb8ab7750b1ccbbcee578df3af6edcba46c367891e319e3b874366c91b2e
Deleted: sha256:5ff949a6a98fa0b9294d5feab73bc2bd31947ecdf546d426d49401a5a5d8b9f4
Deleted: sha256:5e4268f1622d7392ab023aa0c458ee836bda8833e0b0f9d6b3333fff071bb761
Deleted: sha256:f9d1f11193bf543add78ce5660c14322fe3e03e957e07e2f6c4bbc3483fa2201
Deleted: sha256:5e2c15d15d3c100456584750cce4319bb58c9360f5dc2aa80a6ab92cf9910184
Deleted: sha256:ddf4cde2ad1fd66d3c8ea0d44fbd044cfa2928439880d5df6478af4f86e8efef
Deleted: sha256:958ed2862447477e5282173a7b21fbf9a5c83b8452b6e808f654fcea08613454
Deleted: sha256:27123a71e85e0540333291adccf7b9c340d089e8c3717c380d3b75cc8c7df90f

强制删除 

docker rmi  -f  镜像ID

删除全部

docker rmi  -f  $(docker images -qa)	

删除多个

docker rmi  -f  镜像名1:tag 镜像名2:tag	

11.查看镜像/容器/数据卷所占空间

docker system df
[root@localhost ~]# docker system df 
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              12                  11                  7.769GB             737.3MB (9%)
Containers          13                  1                   461MB               461MB (100%)
Local Volumes       9                   5                   710.5MB             501.2MB (70%)
Build Cache         0                   0                   0B                  0B