一: 查看本地镜像命令 docker image list[rootlocalhost ~]# 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[rootlocalhost ~]#二: 搜索官方镜像由于国外网站访问不了我们这里是在国内镜像站搜索镜像命令docker search 镜像站域名/镜像名[rootlocalhost ~]# 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 openjdk81…0linfx0/centos7 CentOS7 Repository0kolab/centos7 Kolab16based on CentOS75nitra/centos7 Container CentOS7 with systemd1nclans/centos70[rootlocalhost ~]#三: 按星级搜索镜像按星级搜索镜像实际上就是在搜索镜像命令的基础上面加上-f stars数字即可# 这里我们搜索stars大于10的镜像[rootlocalhost ~]# docker search docker.1ms.run/centos7 -f stars10NAME DESCRIPTION STARS OFFICIAL rpmbuild/centos7 CentOS7RPM package building environment18[rootlocalhost ~]#四: 拉取镜像命令docker pull 镜像名注意如果镜像名后面不跟版本号我们默认拉取的是最新的版本号[rootlocalhost ~]# docker pull centos:77: Pulling from library/centos 2d473b07cdd5: Already exists Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Status: Downloaded newer imageforcentos:7 docker.io/library/centos:7[rootlocalhost ~]#五: 查看镜像详情查看镜像详细信息需要通过镜像IDdocker image list 可以看到已经下载的本地镜像ID命令docker image inspect 镜像ID[rootlocalhost ~]# 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[rootlocalhost ~]# docker inspect 93165d051206[{Id:sha256:93165d051206cc2ee6804a233effad28ed3db70faba8f86ee5b4ea770e11d6ac,RepoTags:[192.168.255.157:5000/nginx:latest,nginx:latest],RepoDigests:[192.168.255.157:5000/nginxsha256:dc0c700cbecf47f20bd5b5875c7dc878f6f5587dd7da251d369eafd3678004ff,nginxsha256:800e7c98538c6bf725f5177e841aa720ae0ed1c378bbea368b6330bfe18a36b3],六: 删除镜像命令删除镜像docker rmi 镜像id强制删除在最后加上 --force删除所有镜像docker rmi $(docker images -q)查看镜像id docker images -q# 删除单个镜像[rootlocalhost ~]# 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[rootlocalhost ~]# docker rmi centos:7Untagged: centos:7 Untagged: centossha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9[rootlocalhost ~]# docker rmi 6f7eed944dacUntagged: docker_image_commit:7 Deleted: sha256:6f7eed944dac11d726165a6bd5f01aefccf546c035d8b8c56e6883ca4da16191 Deleted: sha256:24f3a40fd1def6ffb1f4b5445ed58689efe9109b01ab80495b57cf08bd20590f[rootlocalhost ~]#七: 给镜像打tag给已有的镜像添加一个新的 “标签tag”相当于给镜像起一个 “别名”。命令 docker tag 源镜像名 新起的镜像名[rootlocalhost ~]# docker tag centos:5 centos:5.1[rootlocalhost ~]# 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[rootlocalhost ~]#八: 查看镜像制作过程命令docker history 镜像名[rootlocalhost ~]# docker history centos:5IMAGE CREATED CREATED BY SIZE COMMENT 1ae98b2c895d9years ago /bin/sh-c#(nop) CMD [/bin/bash] 0Bmissing9years ago /bin/sh-c#(nop) LABEL nameCentOS Base Im… 0Bmissing9years ago /bin/sh-c#(nop) ADD file:811d2948907b0dbea… 285MBmissing9years ago /bin/sh-c#(nop) MAINTAINER The CentOS Pro… 0B[rootlocalhost ~]#
docker基础_镜像使用
发布时间:2026/7/5 6:09:26
一: 查看本地镜像命令 docker image list[rootlocalhost ~]# 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[rootlocalhost ~]#二: 搜索官方镜像由于国外网站访问不了我们这里是在国内镜像站搜索镜像命令docker search 镜像站域名/镜像名[rootlocalhost ~]# 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 openjdk81…0linfx0/centos7 CentOS7 Repository0kolab/centos7 Kolab16based on CentOS75nitra/centos7 Container CentOS7 with systemd1nclans/centos70[rootlocalhost ~]#三: 按星级搜索镜像按星级搜索镜像实际上就是在搜索镜像命令的基础上面加上-f stars数字即可# 这里我们搜索stars大于10的镜像[rootlocalhost ~]# docker search docker.1ms.run/centos7 -f stars10NAME DESCRIPTION STARS OFFICIAL rpmbuild/centos7 CentOS7RPM package building environment18[rootlocalhost ~]#四: 拉取镜像命令docker pull 镜像名注意如果镜像名后面不跟版本号我们默认拉取的是最新的版本号[rootlocalhost ~]# docker pull centos:77: Pulling from library/centos 2d473b07cdd5: Already exists Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Status: Downloaded newer imageforcentos:7 docker.io/library/centos:7[rootlocalhost ~]#五: 查看镜像详情查看镜像详细信息需要通过镜像IDdocker image list 可以看到已经下载的本地镜像ID命令docker image inspect 镜像ID[rootlocalhost ~]# 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[rootlocalhost ~]# docker inspect 93165d051206[{Id:sha256:93165d051206cc2ee6804a233effad28ed3db70faba8f86ee5b4ea770e11d6ac,RepoTags:[192.168.255.157:5000/nginx:latest,nginx:latest],RepoDigests:[192.168.255.157:5000/nginxsha256:dc0c700cbecf47f20bd5b5875c7dc878f6f5587dd7da251d369eafd3678004ff,nginxsha256:800e7c98538c6bf725f5177e841aa720ae0ed1c378bbea368b6330bfe18a36b3],六: 删除镜像命令删除镜像docker rmi 镜像id强制删除在最后加上 --force删除所有镜像docker rmi $(docker images -q)查看镜像id docker images -q# 删除单个镜像[rootlocalhost ~]# 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[rootlocalhost ~]# docker rmi centos:7Untagged: centos:7 Untagged: centossha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9[rootlocalhost ~]# docker rmi 6f7eed944dacUntagged: docker_image_commit:7 Deleted: sha256:6f7eed944dac11d726165a6bd5f01aefccf546c035d8b8c56e6883ca4da16191 Deleted: sha256:24f3a40fd1def6ffb1f4b5445ed58689efe9109b01ab80495b57cf08bd20590f[rootlocalhost ~]#七: 给镜像打tag给已有的镜像添加一个新的 “标签tag”相当于给镜像起一个 “别名”。命令 docker tag 源镜像名 新起的镜像名[rootlocalhost ~]# docker tag centos:5 centos:5.1[rootlocalhost ~]# 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[rootlocalhost ~]#八: 查看镜像制作过程命令docker history 镜像名[rootlocalhost ~]# docker history centos:5IMAGE CREATED CREATED BY SIZE COMMENT 1ae98b2c895d9years ago /bin/sh-c#(nop) CMD [/bin/bash] 0Bmissing9years ago /bin/sh-c#(nop) LABEL nameCentOS Base Im… 0Bmissing9years ago /bin/sh-c#(nop) ADD file:811d2948907b0dbea… 285MBmissing9years ago /bin/sh-c#(nop) MAINTAINER The CentOS Pro… 0B[rootlocalhost ~]#