【Docker】镜像管理
一、搜索镜像
1、在官方网站搜索镜像
Docker 官方镜像仓库:https://hub.docker.com/
2、docker search 搜索镜像
Usage: docker search [OPTIONS] TERM Search the Docker Hub for images Options: -f, --filter filter Filter output based on conditions provided --format string Pretty-print search using a Go template --limit int Max number of search results (default 25) --no-trunc Don't truncate output
OFFICIAL 官方镜像
AUTOMATED 使用第三方docker服务来编译镜像,可以在互联网上直接拉取到的镜像,减少了繁琐的编译过程
[root@Docker-Ubu1804-p11:~]# docker search centos NAME DESCRIPTION STARS OFFICIAL AUTOMATED centos DEPRECATED; The official build of CentOS. 7568 [OK] kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 36 couchbase/centos7-systemd centos7-systemd images with additional debug… 7 [OK] dokken/centos-7 CentOS 7 image for kitchen-dokken 6 dokken/centos-stream-9 4 dokken/centos-stream-8 4 continuumio/centos5_gcc5_base 3 eclipse/centos_jdk8 CentOS, JDK8, Maven 3, git, curl, nmap, mc, … 3 [OK] dokken/centos-8 CentOS 8 image for kitchen-dokken 3 adoptopenjdk/centos7_build_image 1 spack/centos7 CentOS 7 with Spack preinstalled 1 spack/centos6 CentOS 6 with Spack preinstalled 1 atlas/centos7-atlasos ATLAS CentOS 7 Software Development OS 0 couchbase/centos-72-java-sdk 0 ustclug/centos Official CentOS Image with USTC Mirror 0 couchbase/centos-72-jenkins-core 0 dokken/centos-6 CentOS 6 image for kitchen-dokken 0 datadog/centos-i386 0 couchbase/centos-70-sdk-build 0 couchbase/centos-69-sdk-build 0 couchbase/centos-69-sdk-nodevtoolset-build 0 bitnami/centos-extras-base 0 corpusops/centos-bare https://github.com/corpusops/docker-images/ 0 bitnami/centos-base-buildpack Centos base compilation image 0 [OK] corpusops/centos centos corpusops baseimage 0
查找超过10赞的镜像
[root@Docker-Ubu1804-p11:~]# docker search --filter=stars=10 centos NAME DESCRIPTION STARS OFFICIAL AUTOMATED centos DEPRECATED; The official build of CentOS. 7568 [OK] kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 36
二、下载镜像
1、docker pull 下载镜像
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST] Pull an image or a repository from a registry Options: -a, --all-tags Download all tagged images in the repository --disable-content-trust Skip image verification (default true) --platform string Set platform if server is multi-platform capable -q, --quiet Suppress verbose output
NAME 镜像名称,通常格式为 仓库服务器地址:端口号/项目名称或作者/镜像名称
:TAG 镜像版本号,如不指定,默认为 latest,即下载最新版本
@DISGEST 镜像摘要信息,较少使用,需要提前查询
下载最新版busybox镜像
[root@Docker-Ubu1804-p11:~]# docker pull busybox Using default tag: latest #使用默认版本号:latest latest: Pulling from library/busybox 5cc84ad355aa: Pull complete Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678 #镜像 DISGEST 摘要信息 Status: Downloaded newer image for busybox:latest docker.io/library/busybox:latest #镜像完成下载路径
下载指定版本busybox
对应镜像的可用版本信息可在镜像仓库中 TAG 下查看
[root@Docker-Ubu1804-p11:~]# docker pull busybox:1.36 1.36: Pulling from library/busybox 4b35f584bb4f: Pull complete Digest: sha256:b5d6fe0712636ceb7430189de28819e195e8966372edfc2d9409d79402a0dc16 Status: Downloaded newer image for busybox:1.36 docker.io/library/busybox:1.36 [root@Docker-Ubu1804-p11:~]#
指定下载源下载1.35.0版本 busybox
[root@Docker-Ubu1804-p11:~]# docker pull docker.io/library/busybox:1.35.0 1.35.0: Pulling from library/busybox f643e116a03d: Pull complete Digest: sha256:130df6999605f982ec67e5bee29d3a52614a075e949490f0a41702ee1dd98f3f Status: Downloaded newer image for busybox:1.35.0 docker.io/library/busybox:1.35.0 [root@Docker-Ubu1804-p11:~]#
通过Digest下载mysql镜像
[root@Docker-Ubu1804-p11:~]# docker pull mysql@sha256:b45a7c3e6fb15526e8bf62ebb940cd460617e36f46155b8514fd9c9388231817
2、镜像下载存放目录
镜像默认下载存放目录:/var/lib/docker/overlay2/<镜像ID>
三、查看本地镜像
1、docker images 可查看本地镜像信息
[root@Docker-Ubu1804-p11:~]# docker images --help Usage: docker images [OPTIONS] [REPOSITORY[:TAG]] List images Options: -a, --all Show all images (default hides intermediate images) --digests Show digests -f, --filter filter Filter output based on conditions provided --format string Pretty-print images using a Go template --no-trunc Don't truncate output -q, --quiet Only show numeric IDs
##docker images 与 docker image ls 结果相同
#REPOSITORY 镜像所属仓库名称
#TAG 镜像版本号(标识,默认latest)
#IMAGE ID 镜像ID,如果镜像ID相同说明本质上是同一镜像
#CREATED 镜像创建时间
#SIZE 镜像大小
[root@Docker-Ubu1804-p11:~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 17 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 17 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB nginx latest 605c77e624dd 16 months ago 141MB alpine latest c059bfaa849c 17 months ago 5.59MB ubuntu 18.04 5a214d77f5d7 19 months ago 63.1MB centos 7 eeb6ee3f44bd 19 months ago 204MB [root@Docker-Ubu1804-p11:~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 17 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 17 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB nginx latest 605c77e624dd 16 months ago 141MB alpine latest c059bfaa849c 17 months ago 5.59MB ubuntu 18.04 5a214d77f5d7 19 months ago 63.1MB centos 7 eeb6ee3f44bd 19 months ago 204MB
显示镜像完整ID
[root@Docker-Ubu1804-p11:~]# docker images --no-trunc REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 sha256:f65a9531bfc75f2255c35af79d712c385365edc8235862944d81b43c84ad519b 17 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 sha256:4919aacb5ea0aa5d93a5f386f0df115c74cf774ff2df2bd68caf12b66fee3fe7 17 hours ago 562MB janzen/centos7 v1.0 sha256:b9d392225b3e0e7a409f577c7100e38c7f3928aa2f38890e1f839c2aa1147335 2 days ago 529MB busybox 1.36 sha256:7cfbbec8963d8f13e6c70416d6592e1cc10f47a348131290a55d43c3acab3fb9 5 weeks ago 4.86MB busybox 1.35.0 sha256:a711f05d33845e2e9deffcfcc5adf082d7c6e97e3e3a881d193d9aae38f092a8 16 months ago 1.24MB busybox latest sha256:beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a 16 months ago 1.24MB nginx latest sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85 16 months ago 141MB alpine latest sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18 17 months ago 5.59MB ubuntu 18.04 sha256:5a214d77f5d747e6ed81632310baa6190301feeb875cf6bf9da560108fa09972 19 months ago 63.1MB centos 7 sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9 19 months ago 204MB
仅显示镜像简要ID
[root@Docker-Ubu1804-p11:~]# docker images -q
f65a9531bfc7
4919aacb5ea0
b9d392225b3e
7cfbbec8963d
a711f05d3384
beae173ccac6
605c77e624dd
c059bfaa849c
5a214d77f5d7
eeb6ee3f44bd
查看特定镜像信息
[root@Docker-Ubu1804-p11:~]# docker images busybox REPOSITORY TAG IMAGE ID CREATED SIZE busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB
[root@Docker-Ubu1804-p11:~]# docker images janzen/* REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 17 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 17 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB
查看指定镜像的详细xinx
[root@Docker-Ubu1804-p11:~]# docker image inspect alpine [ { "Id": "sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18", "RepoTags": [ "alpine:latest" ], "RepoDigests": [ "alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300" ], "Parent": "", "Comment": "", "Created": "2021-11-24T20:19:40.483367546Z", "Container": "4292e8ed2ef2b6dc4bbaf8e1cda0cb5f95b96adc4aa2da3d15181b54d07a0b34", "ContainerConfig": { "Hostname": "4292e8ed2ef2", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh", "-c", "#(nop) ", "CMD [\"/bin/sh\"]" ], "Image": "sha256:b747534ae29d08c0c84cc4326caf04e873c6d02bb67cd9c7644be2b4fa8d2f31", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "DockerVersion": "20.10.7", "Author": "", "Config": { "Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh" ], "Image": "sha256:b747534ae29d08c0c84cc4326caf04e873c6d02bb67cd9c7644be2b4fa8d2f31", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": null }, "Architecture": "amd64", "Os": "linux", "Size": 5585772, "VirtualSize": 5585772, "GraphDriver": { "Data": { "MergedDir": "/var/lib/docker/overlay2/f4846cc67ef296f1eba1438538a63822c70a7890dbf2d9696c305635f705ebb4/merged", "UpperDir": "/var/lib/docker/overlay2/f4846cc67ef296f1eba1438538a63822c70a7890dbf2d9696c305635f705ebb4/diff", "WorkDir": "/var/lib/docker/overlay2/f4846cc67ef296f1eba1438538a63822c70a7890dbf2d9696c305635f705ebb4/work" }, "Name": "overlay2" }, "RootFS": { "Type": "layers", "Layers": [ "sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759" ] }, "Metadata": { "LastTagTime": "0001-01-01T00:00:00Z" } } ]
四、镜像导出
1、docker save 命令
Usage: docker save [OPTIONS] IMAGE [IMAGE...] Save one or more images to a tar archive (streamed to STDOUT by default) Options: -o, --output string Write to a file, instead of STDOUT
#常用写法 docker save IMAGE1 IMAGE2 ... > /path/file.tar docker save -o /path/file.tar IMAGE1 IMAGE2 ...
将janzen项目的镜像导出 至 janzen_web_images.tar
[root@Docker-Ubu1804-p11:~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 17 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 17 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB nginx latest 605c77e624dd 16 months ago 141MB alpine latest c059bfaa849c 17 months ago 5.59MB ubuntu 18.04 5a214d77f5d7 19 months ago 63.1MB centos 7 eeb6ee3f44bd 19 months ago 204MB [root@Docker-Ubu1804-p11:~]# docker save janzen/app1:v3.0 janzen/nginx-centos7:1.20.1-v2.0 > janzen_web_images.tar [root@Docker-Ubu1804-p11:~]# ls disk.sh image.tar issue janzen_web_images.tar os.version redis_install.sh system_info.sh
将janzen项目镜像及基础镜像 导出 至 janzen_images.tar
[root@Docker-Ubu1804-p11:~]# docker save -o janzen_images.tar janzen/app1:v3.0 janzen/nginx-centos7:1.20.1-v2.0 janzen/centos7:v1.0 [root@Docker-Ubu1804-p11:~]# ls disk.sh image.tar issue janzen_images.tar janzen_web_images.tar os.version redis_install.sh system_info.sh
五、镜像导入
1、docker load 命令导入镜像数据
Usage: docker load [OPTIONS] Load an image from a tar archive or STDIN Options: -i, --input string Read from tar archive file, instead of STDIN -q, --quiet Suppress the load output
# 常用写法 docker load -i /path/imagefile docker load < /path/imagefile
将 janzen_images.tar 中的镜像导入本地
[root@Template-CentOS7-7 ~]# ls anaconda-ks.cfg docker docker-19.03.15.tgz janzen_images.tar [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE [root@Template-CentOS7-7 ~]# docker load -i janzen_images.tar 174f56854903: Loading layer [==================================================>] 211.7MB/211.7MB b82538224854: Loading layer [==================================================>] 362.4MB/362.4MB 188c1c5e9297: Loading layer [==================================================>] 14.34kB/14.34kB f04a4d2ea341: Loading layer [==================================================>] 9.956MB/9.956MB Loaded image: janzen/app1:v3.0 Loaded image: janzen/nginx-centos7:1.20.1-v2.0 ae552106ea81: Loading layer [==================================================>] 328.4MB/328.4MB Loaded image: janzen/centos7:v1.0 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB
将 busybox_image.tar 中的镜像导入本地
[root@Template-CentOS7-7 ~]# ls anaconda-ks.cfg busybox_image.tar docker docker-19.03.15.tgz janzen_images.tar [root@Template-CentOS7-7 ~]# docker load < busybox_image.tar 01fd6df81c8e: Loading layer [==================================================>] 1.459MB/1.459MB Loaded image: busybox:latest 6008d842465c: Loading layer [==================================================>] 1.463MB/1.463MB Loaded image: busybox:1.35.0 baacf561cfff: Loading layer [==================================================>] 5.092MB/5.092MB Loaded image: busybox:1.36 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB
六、删除镜像
1、docker rmi 删除镜像
Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] docker image rm [OPTIONS] IMAGE [IMAGE...] Remove one or more images Options: -f, --force Force removal of the image --no-prune Do not delete untagged parents
删除镜像 busybox:latest
[root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB [root@Template-CentOS7-7 ~]# docker rmi busybox Untagged: busybox:latest Deleted: sha256:beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a Deleted: sha256:01fd6df81c8ec7dd24bbbd72342671f41813f992999a3471b9d9cbc44ad88374 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB
删除多个 busybox 镜像
[root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB [root@Template-CentOS7-7 ~]# docker rmi busybox:1.36 a7 Untagged: busybox:1.36 Deleted: sha256:7cfbbec8963d8f13e6c70416d6592e1cc10f47a348131290a55d43c3acab3fb9 Deleted: sha256:baacf561cfff825708763ce7ee4a18293716c533e6ece3bd39009a5fb3c804d2 Untagged: busybox:1.35.0 Deleted: sha256:a711f05d33845e2e9deffcfcc5adf082d7c6e97e3e3a881d193d9aae38f092a8 Deleted: sha256:6008d842465c80dc1176892f60c8f0334c93b2b8ac45abd9310f01f448d20a25 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB [root@Template-CentOS7-7 ~]#
删除被关闭状态下容器使用的镜像
[root@Template-CentOS7-7 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d6302b91967a janzen/centos7:v1.0 "/bin/bash" 6 seconds ago Exited (0) 5 seconds ago optimistic_goodall [root@Template-CentOS7-7 ~]# docker rmi janzen/centos7:v1.0 Error response from daemon: conflict: unable to remove repository reference "janzen/centos7:v1.0" (must force) - container d6302b91967a is using its referenced image b9d392225b3e [root@Template-CentOS7-7 ~]# docker rmi -f janzen/centos7:v1.0 Untagged: janzen/centos7:v1.0 Deleted: sha256:b9d392225b3e0e7a409f577c7100e38c7f3928aa2f38890e1f839c2aa1147335 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB [root@Template-CentOS7-7 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d6302b91967a b9d392225b3e "/bin/bash" About a minute ago Exited (0) About a minute ago optimistic_goodall [root@Template-CentOS7-7 ~]#
删除运行态下容器使用的镜像
[root@Template-CentOS7-7 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2a60db370df1 janzen/app1:v3.0 "nginx" 9 seconds ago Up 8 seconds 0.0.0.0:32771->80/tcp, 0.0.0.0:32770->443/tcp nervous_kilby [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB [root@Template-CentOS7-7 ~]# docker rmi janzen/app1 Error: No such image: janzen/app1 [root@Template-CentOS7-7 ~]# docker rmi janzen/app1:v3.0 Error response from daemon: conflict: unable to remove repository reference "janzen/app1:v3.0" (must force) - container 2a60db370df1 is using its referenced image f65a9531bfc7 [root@Template-CentOS7-7 ~]# docker rmi -f janzen/app1:v3.0 Untagged: janzen/app1:v3.0 [root@Template-CentOS7-7 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2a60db370df1 f65a9531bfc7 "nginx" About a minute ago Up About a minute 0.0.0.0:32771->80/tcp, 0.0.0.0:32770->443/tcp nervous_kilby [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB [root@Template-CentOS7-7 ~]# docker rmi -f f65a9531bfc7 Error response from daemon: conflict: unable to delete f65a9531bfc7 (cannot be forced) - image is being used by running container 2a60db370df1 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB
删除所有镜像
[root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 19 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 19 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB [root@Template-CentOS7-7 ~]# docker images -q | xargs docker rmi -f Untagged: janzen/app1:v3.0 Deleted: sha256:f65a9531bfc75f2255c35af79d712c385365edc8235862944d81b43c84ad519b Deleted: sha256:d3d543a1d2e9f8f7afe6c61b9db492ab3c6def352ea18677aac4e731fcb85bfc Deleted: sha256:771e52caf72cf0b7d4783e410a30deb25bd8a4fcb0658806e76a8dca9baaf86f Untagged: janzen/nginx-centos7:1.20.1-v2.0 Deleted: sha256:4919aacb5ea0aa5d93a5f386f0df115c74cf774ff2df2bd68caf12b66fee3fe7 Deleted: sha256:48b25e5bf2accbd397c4337388696c4e261a7982f06d1de2470da61dc1422397 Untagged: janzen/centos7:v1.0 Deleted: sha256:b9d392225b3e0e7a409f577c7100e38c7f3928aa2f38890e1f839c2aa1147335 Deleted: sha256:cced0c561bd144d343277c13771fd00b00c04abbd89c78d5f003785006a0b04d Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02 Untagged: busybox:1.36 Deleted: sha256:7cfbbec8963d8f13e6c70416d6592e1cc10f47a348131290a55d43c3acab3fb9 Deleted: sha256:baacf561cfff825708763ce7ee4a18293716c533e6ece3bd39009a5fb3c804d2 Untagged: busybox:1.35.0 Deleted: sha256:a711f05d33845e2e9deffcfcc5adf082d7c6e97e3e3a881d193d9aae38f092a8 Deleted: sha256:6008d842465c80dc1176892f60c8f0334c93b2b8ac45abd9310f01f448d20a25 Untagged: busybox:latest Deleted: sha256:beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a Deleted: sha256:01fd6df81c8ec7dd24bbbd72342671f41813f992999a3471b9d9cbc44ad88374 [root@Template-CentOS7-7 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE
七、镜像添加标签
1、docker tag 命令添加镜像标签
Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
将镜像 janzen/app1:v3.0 添加标签修改为latest版
[root@Docker-Ubu1804-p11:~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 18 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB nginx latest 605c77e624dd 16 months ago 141MB alpine latest c059bfaa849c 17 months ago 5.59MB ubuntu 18.04 5a214d77f5d7 19 months ago 63.1MB centos 7 eeb6ee3f44bd 19 months ago 204MB [root@Docker-Ubu1804-p11:~]# docker tag janzen/app1:v3.0 janzen/app1 [root@Docker-Ubu1804-p11:~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE janzen/app1 latest f65a9531bfc7 18 hours ago 572MB janzen/app1 v3.0 f65a9531bfc7 18 hours ago 572MB janzen/nginx-centos7 1.20.1-v2.0 4919aacb5ea0 19 hours ago 562MB janzen/centos7 v1.0 b9d392225b3e 2 days ago 529MB busybox 1.36 7cfbbec8963d 5 weeks ago 4.86MB busybox 1.35.0 a711f05d3384 16 months ago 1.24MB busybox latest beae173ccac6 16 months ago 1.24MB nginx latest 605c77e624dd 16 months ago 141MB alpine latest c059bfaa849c 17 months ago 5.59MB ubuntu 18.04 5a214d77f5d7 19 months ago 63.1MB centos 7 eeb6ee3f44bd 19 months ago 204MB
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步