Docker容器技术
Docker基础概念
Docker安装配置
通过docker registry搭建私有仓库
Dockerfile编写学习
数据卷管理
Docker 镜像
Docker容器管理
daemon.json配置示例
Dcocker网络互联
Docker部署nextcloud网盘
Watchtower-容器的自动升级
想要轻松上手Docker?Portainer帮你实现零基础快速部署!
Nextcloud搭建
Docker搭建Mrdoc
Mrdoc迁移记录
Docker部署wordpress博客
Docker部署个人密码管理平台bitwarden
Docker-compose安装配置
Docker-compose搭建小说阅读器
Docker搭建青龙面板
Docker搭建自己的导航页dashy
uptime-kuma监控面板部署
容器搭建Nas-tool及相关套件
本文档使用 MrDoc 发布
-
+
首页
Docker 镜像
# docker镜像 docker镜像类似于虚拟机的iso文件,用于启动容器。 ## 查找镜像 镜像存在于docker 仓库中,每个镜像可以有多个tag标签代表了不同版本或者特殊标记。默认查找docker hub公开仓库。 ``` # 使用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注意不要删错了。 ```
Chuck
2022年12月23日 17:07
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码