当前位置: 首页 > news >正文

docker基础_镜像使用

一: 查看本地镜像

  • 命令: docker image list
[root@localhost ~]# docker image listREPOSITORY TAG IMAGE ID CREATED SIZE docker_image_commit76f7eed944dac5weeks ago 161MB192.168.255.157:5000/nginx latest 93165d0512066weeks ago 161MB nginx latest 93165d0512066weeks ago 161MB registry latest 53c26cd623112months ago62.4MB mysql5.75107333e08a82years ago 501MB uifd/ui-for-docker latest 965940f98fa59years ago8.1MB centos51ae98b2c895d9years ago 285MB[root@localhost ~]#

二: 搜索官方镜像

由于国外网站访问不了,我们这里是在国内镜像站搜索镜像

  • 命令:docker search 镜像站域名/镜像名
[root@localhost ~]# docker search docker.1ms.run/centos7NAME DESCRIPTION STARS OFFICIAL paigeeworld/centos7 Centos7 with apache, iperf3, nmap,ssh7lamho/centos72rpmbuild/centos7 CentOS7RPM package building environment18getgambacom/centos7 CentOS71spack/centos7 CentOS7with Spack preinstalled2rmtm/centos7 CentOS7 BaselineforRMTM0henker/centos700702/centos7 A centos7 with usual utils0nodesource/centos7 The Official NodeSource Docker Images2jinwoo/centos7 centos70caio2k/centos7 centos7 with supervisord and vagrant user0roboxes/centos7 A generic CentOS7base image.4vearsa/centos70m411momo/centos7 ZSH Shell CentOS70jeongho/centos7 Docker imageforcentos70pantsbuild/centos70lstrcm/centos70level077/centos7 centos70waffleimage/centos7 Centos:7 with systemd andsshrunning0charlesjimi/centos7 my linux centos7makedockerimg0blankhang/centos7 centos7 with chinese lanugage and openjdk810linfx0/centos7 CentOS7 Repository0kolab/centos7 Kolab16based on CentOS75nitra/centos7 Container CentOS7 with systemd1nclans/centos70[root@localhost ~]#

三: 按星级搜索镜像

按星级搜索镜像,实际上就是在搜索镜像命令的基础上面加上-f stars=数字即可

# 这里我们搜索stars大于10的镜像[root@localhost ~]# docker search docker.1ms.run/centos7 -f stars=10NAME DESCRIPTION STARS OFFICIAL rpmbuild/centos7 CentOS7RPM package building environment18[root@localhost ~]#

四: 拉取镜像

  • 命令:docker pull 镜像名
  • 注意:如果镜像名后面不跟版本号,我们默认拉取的是最新的版本号
[root@localhost ~]# docker pull centos:77: Pulling from library/centos 2d473b07cdd5: Already exists Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Status: Downloaded newer imageforcentos:7 docker.io/library/centos:7[root@localhost ~]#

五: 查看镜像详情

查看镜像详细信息,需要通过镜像ID,docker image list 可以看到已经下载的本地镜像ID

  • 命令:docker image inspect 镜像ID
[root@localhost ~]# docker image listREPOSITORY TAG IMAGE ID CREATED SIZE docker_image_commit76f7eed944dac5weeks ago 161MB192.168.255.157:5000/nginx latest 93165d0512066weeks ago 161MB nginx latest 93165d0512066weeks ago 161MB registry latest 53c26cd623112months ago62.4MB mysql5.75107333e08a82years ago 501MB centos7eeb6ee3f44bd4years ago 204MB uifd/ui-for-docker latest 965940f98fa59years ago8.1MB centos51ae98b2c895d9years ago 285MB[root@localhost ~]# docker inspect 93165d051206[{"Id":"sha256:93165d051206cc2ee6804a233effad28ed3db70faba8f86ee5b4ea770e11d6ac","RepoTags":["192.168.255.157:5000/nginx:latest","nginx:latest"],"RepoDigests":["192.168.255.157:5000/nginx@sha256:dc0c700cbecf47f20bd5b5875c7dc878f6f5587dd7da251d369eafd3678004ff","nginx@sha256:800e7c98538c6bf725f5177e841aa720ae0ed1c378bbea368b6330bfe18a36b3"],

六: 删除镜像

命令:

  • 删除镜像:docker rmi 镜像id
  • 强制删除:在最后加上 --force
  • 删除所有镜像:docker rmi $(docker images -q)
  • 查看镜像id: docker images -q
# 删除单个镜像[root@localhost ~]# docker image listREPOSITORY TAG IMAGE ID CREATED SIZE docker_image_commit76f7eed944dac5weeks ago 161MB192.168.255.157:5000/nginx latest 93165d0512066weeks ago 161MB nginx latest 93165d0512066weeks ago 161MB registry latest 53c26cd623112months ago62.4MB mysql5.75107333e08a82years ago 501MB centos7eeb6ee3f44bd4years ago 204MB uifd/ui-for-docker latest 965940f98fa59years ago8.1MB centos51ae98b2c895d9years ago 285MB[root@localhost ~]# docker rmi centos:7Untagged: centos:7 Untagged: centos@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9[root@localhost ~]# docker rmi 6f7eed944dacUntagged: docker_image_commit:7 Deleted: sha256:6f7eed944dac11d726165a6bd5f01aefccf546c035d8b8c56e6883ca4da16191 Deleted: sha256:24f3a40fd1def6ffb1f4b5445ed58689efe9109b01ab80495b57cf08bd20590f[root@localhost ~]#

七: 给镜像打tag

给已有的镜像添加一个新的 “标签(tag)”,相当于给镜像起一个 “别名”。

  • 命令: docker tag 源镜像名 新起的镜像名
[root@localhost ~]# docker tag centos:5 centos:5.1[root@localhost ~]# docker image listREPOSITORY TAG IMAGE ID CREATED SIZE192.168.255.157:5000/nginx latest 93165d0512066weeks ago 161MB nginx latest 93165d0512066weeks ago 161MB registry latest 53c26cd623112months ago62.4MB mysql5.75107333e08a82years ago 501MB uifd/ui-for-docker latest 965940f98fa59years ago8.1MB centos51ae98b2c895d9years ago 285MB centos5.11ae98b2c895d9years ago 285MB[root@localhost ~]#

八: 查看镜像制作过程

  • 命令:docker history 镜像名
[root@localhost ~]# docker history centos:5IMAGE CREATED CREATED BY SIZE COMMENT 1ae98b2c895d9years ago /bin/sh-c#(nop) CMD ["/bin/bash"] 0B<missing>9years ago /bin/sh-c#(nop) LABEL name=CentOS Base Im… 0B<missing>9years ago /bin/sh-c#(nop) ADD file:811d2948907b0dbea… 285MB<missing>9years ago /bin/sh-c#(nop) MAINTAINER The CentOS Pro… 0B[root@localhost ~]#
http://www.jsqmd.com/news/1126443/

相关文章:

  • 找大庆口碑好的装修公司会踩坑吗?一位业主的真实经历与避坑复盘
  • Windows Defender权限绕过与内核级控制技术:架构解析与实现指南
  • 民营企业招标,有权自主决定是否接受联合体投标吗?
  • 第一章:初识 C 语言 —— 编程世界的基石
  • 如何通过Diablo Edit2角色编辑器打造个性化暗黑破坏神2游戏体验
  • 错题本为什么常常没有效果
  • 突破性逆向工程:JPEXS Free Flash Decompiler深度解析与实战指南
  • Topit:终极Mac窗口置顶神器,三步解决多窗口遮挡难题
  • 支付系统接口安全全解:从加密验签原理到亿级流量架构实战
  • 只剩两个月了!2026年9月PMP末班车:现在不冲,12月就得硬啃新考纲
  • 三步搞定B站缓存合并:安卓用户最实用的视频导出终极指南
  • AI Agent工作流中错误偏差累积的成因与防御实践
  • AAA第六周小学期学习笔记
  • 拼多多笔试真题-对角线遍历矩阵(C++/Py/Java /Js/Go)
  • 解放双手的炉石传说智能伴侣:Hearthstone-Script完全解析
  • 如何用PCL启动器轻松打造你的专属Minecraft世界:从零开始的完整指南
  • 机场安检触摸终端选型指南:X光机操作台、证件核验闸机与安检信息系统
  • 如何轻松录制40+平台直播:StreamCap开源工具的完整指南
  • 宏基因组测序
  • LinkSwift:九大网盘直链下载技术方案深度解析
  • 逆向工程入门:从CrackMe实战解析序列号验证与动态调试
  • 企业级RAG权限安全全链路方案:从向量检索到生成的安全实践
  • AI Agent 从入门到封神:24 讲打造你的超级智能体~系列文章08:多模态Agent的构建与应用
  • 钢质、断桥铝防火窗价差成因,原材料与工艺差异详解
  • 如何三步快速清理微信单向好友:终极完整指南
  • 终极指南:专业高效处理华为光猫加密配置文件的完整解决方案
  • NVIDIA深度研究资源实战指南与优化技巧
  • 第021章:ComfyUI文生音频Qwen3-TTS模型数字人音色设计(二)
  • 如何在3分钟内安装DeepL翻译插件:免费开源的专业翻译解决方案
  • 微信好友关系检测终极指南:三步找出单向好友的完整教程