LOVEJOAN

文章 分类 评论
76 9 1453

站点介绍

人生是一场孤独的旅行,没有终点。。。

一键查找,轻松获取!教你如何在Docker Hub中找到最受欢迎的镜像!

chuck 2023-11-30 372 18条评论 Docker Docker

首页 / 正文

docker镜像

docker镜像类似于虚拟机的iso文件,用于启动容器。

查找镜像

镜像存在于docker 仓库中,每个镜像可以有多个tag标签代表了不同版本或者特殊标记。默认查找docker hub公开仓库。

docker hub官网地址:https://hub-stage.docker.com/

# 使用docker search 镜像名称可以查找镜像
[root@localhost keli]# docker search nginx
NAME                                              DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                         17849     [OK]       
bitnami/nginx                                     Bitnami nginx Docker Image                       149                  [OK]
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Contr…   22                   [OK]
# name表示镜像仓库名称,DESCRIPTION镜像仓库描述,STARS表示关注度,星星越多表示收到关注越多,OFFICIAL代表是官方镜像

# 列出stars大于10的镜像
docker search -f stars=10 nginx
# 列出前面5个镜像
docker search nginx --limit 5
# 只列出官方镜像
docker search -f is-official=true nginx
# 格式化输出
镜像描述:.Description
star数量:.StarCount
官方镜像:.IsOfficial
自动构建:.IsAutomated
docker search --format "{{.Name}}: {{.StarCount}}" java

下载镜像

使用docker pull下载镜像到本地。

# 格式:docker pull 镜像仓库名称:tag ,如果没有指定tag,默认为latest
docker pull nginx
docker pull mysql:latest

查看本地镜像

通过docker images查看本地镜像,默认查看所有本地镜像

# 格式 docker images [option]
[root@localhost keli]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
centos8      v2        5ce55143685a   2 days ago      245MB
nginx-test   1.21.5    860010318005   3 days ago      141MB
nginx        latest    605c77e624dd   11 months ago   141MB
wordpress    latest    c3c92cc3dcb1   12 months ago   616MB
registry     latest    b8604a3fe854   13 months ago   26.2MB
centos       latest    5d0da3dc9764   15 months ago   231MB
# REPOSITORY 镜像的仓库源,tag,镜像的标签,image id每个镜像唯一的ID,created镜像的创建日期或更新日期,size镜像大小

# 列出本地所有的镜像
docker images -a
# 只显示镜像ID
docker images -q
# 显示镜像的摘要信息
docker images --digests
# 显示完整的镜像信息
docker images --no-trunc
# 查看镜像的创建过程,显示每一层的操作
[root@localhost keli]# docker history nginx-test:1.21.5
IMAGE          CREATED         CREATED BY                                       SIZE      COMMENT
860010318005   3 days ago      /bin/bash                                        27B       test create image
<missing>      11 months ago   /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B        
<missing>      11 months ago   /bin/sh -c #(nop)  STOPSIGNAL SIGQUIT            0B        
<missing>      11 months ago   /bin/sh -c #(nop)  EXPOSE 80                     0B        
<missing>      11 months ago   /bin/sh -c #(nop)  ENTRYPOINT ["/docker-entr…   0B        
<missing>      11 months ago   /bin/sh -c #(nop) COPY file:09a214a3e07c919a…   4.61kB    
<missing>      11 months ago   /bin/sh -c #(nop) COPY file:0fd5fca330dcd6a7…   1.04kB    
<missing>      11 months ago   /bin/sh -c #(nop) COPY file:0b866ff3fc1ef5b0…   1.96kB    
<missing>      11 months ago   /bin/sh -c #(nop) COPY file:65504f71f5855ca0…   1.2kB     
<missing>      11 months ago   /bin/sh -c set -x     && addgroup --system -…   61.1MB    
<missing>      11 months ago   /bin/sh -c #(nop)  ENV PKG_RELEASE=1~bullseye    0B        
<missing>      11 months ago   /bin/sh -c #(nop)  ENV NJS_VERSION=0.7.1         0B        
<missing>      11 months ago   /bin/sh -c #(nop)  ENV NGINX_VERSION=1.21.5      0B        
<missing>      12 months ago   /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B        
<missing>      12 months ago   /bin/sh -c #(nop)  CMD ["bash"]                  0B        
<missing>      12 months ago   /bin/sh -c #(nop) ADD file:09675d11695f65c55…   80.4MB
# 镜像标签
docker tag mysql:latest mysql:v1
[root@localhost keli]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
centos8      v2        5ce55143685a   2 days ago      245MB
nginx-test   1.21.5    860010318005   3 days ago      141MB
nginx        latest    605c77e624dd   11 months ago   141MB
wordpress    latest    c3c92cc3dcb1   12 months ago   616MB
mysql        latest    3218b38490ce   12 months ago   516MB
mysql        v1        3218b38490ce   12 months ago   516MB

删除本地镜像

使用docker rmi 镜像ID来删除本地镜像。

# 普通删除,只能删除没有容器引用的镜像
docker rmi nginx
# 强制删除-f
docker rmi -f nginx
# 全部删除,通过查询到的镜像ID全部删除
docker rmi -f $(docker images -q)
# 如果本地镜像有多个tag注意不要删错了。

评论(18)

  1. 1 游客 2025-03-27 23:39 回复

    555ww0Pioa1') OR 763=(SELECT 763 FROM PG_SLEEP(15))--

  2. 1 游客 2025-03-27 23:38 回复

    555-1 waitfor delay '0:0:15' --

  3. 1 游客 2025-03-27 23:37 回复

    555

  4. 1 游客 2025-03-27 23:36 回复

    555

  5. 1 游客 2025-03-27 23:35 回复

    555

  6. @@DHE3H 游客 2025-03-27 23:33 回复

    555

  7. 1jN1Eltu9'; waitfor delay '0:0:15' -- 游客 2025-03-27 23:31 回复

    555

  8. 1-1; waitfor delay '0:0:15' -- 游客 2025-03-27 23:30 回复

    555

  9. -1' OR 2+366-366-1=0+0+0+1 -- 游客 2025-03-27 23:28 回复

    555

  10. -1 OR 3+586-586-1=0+0+0+1 游客 2025-03-27 23:28 回复

    555

  11. -1 OR 2+586-586-1=0+0+0+1 游客 2025-03-27 23:28 回复

    555

  12. -1 OR 3+617-617-1=0+0+0+1 -- 游客 2025-03-27 23:28 回复

    555

  13. -1 OR 2+617-617-1=0+0+0+1 -- 游客 2025-03-27 23:28 回复

    555

  14. 1 游客 2025-03-27 23:28 回复

    555

  15. 1 游客 2025-03-27 23:27 回复

    555

  16. 1 游客 2025-03-27 23:26 回复

    555

  17. 1 游客 2025-03-27 23:24 回复

    555

  18. 1 游客 2025-03-27 23:24 回复

    555

热门文章

最新评论

  • 1

    555fulIdEqZ' OR 160=(SELECT 160 FROM PG_SLEEP(15))--

  • 1

    555-1)) OR 58=(SELECT 58 FROM PG_SLEEP(15))--

  • 1

    555-1) OR 13=(SELECT 13 FROM PG_SLEEP(15))--

  • 1

    555-1 OR 475=(SELECT 475 FROM PG_SLEEP(15))--

  • 1

    555

  • 1

    555

  • 1

    5554FobGRsu') OR 696=(SELECT 696 FROM PG_SLEEP(15))--

  • 1

    555C9F0upP1' OR 504=(SELECT 504 FROM PG_SLEEP(15))--

  • 1

    555

  • 1-1; waitfor delay '0:0:15' --

    555

日历

2025年05月

    123
45678910
11121314151617
18192021222324
25262728293031

文章目录