【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
【Docker】镜像管理的更多相关文章
- Docker镜像管理基础篇
Docker镜像管理基础篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Docker Images Docker镜像还有启动容器所需要的文件系统及其内容,因此,其用于创建并启 ...
- Devops(四):Docker 镜像管理
参考 <Docker中上传镜像到docker hub中> <Docker 镜像管理> <通过容器提交镜像(docker commit)以及推送镜像(docker push ...
- 2、docker镜像管理
Docker镜像管理 镜像是Docker容器的基础,想运行一个Docker容器就需要有镜像.我们上面已经学会了使用search搜索镜像.那么这个镜像是怎么创建的呢? 创建镜像 镜像的创建有以下几种方法 ...
- Docker学习第一天(Docker入门&&Docker镜像管理)
简介 今天小区的超市买零食老板给我说再过几天可能就卖完了我有点诧异,老板又说厂家不生产了emmm 今天总算开始docker了! 1.Docker? 1.什么是Docker Docker 是一个开源的应 ...
- 三、docker镜像管理
一.docker镜像管理 1.1.镜像搜索-search 从docker镜像仓库模糊搜索镜像 用法: docker search 镜像关键字 [root@zutuanxue ~]# docker se ...
- paas架构之docker——镜像管理
1. 镜像管理 1.1. 列出镜像 Sudo docker images 1.2. 查看镜像 Sudo docker images xxxx 1.3. 拉取镜像 Sudo docker pull ub ...
- Docker镜像管理
镜像是docker的三大核心概念之一.可以用来创建容器. Docker的镜像实际上由一层一层的文件系统组成,这种层级的文件系统被称为UnionFS.镜像可以基于Dockerfile构建,Dockerf ...
- 004.Docker镜像管理
一 镜像基本操作 镜像是一个包含程序运行必要依赖环境和代码的只读文件,其本质是磁盘上一系列文件的集合.它采用分层的文件系统,将每一次改变以读写层的形式增加到原来的只读文件上.镜像是容器运行的基石. 1 ...
- docker镜像管理(二)
docker镜像 docker镜像含有启动容器所需要的文件系统和内容,因此,其用于创建并启动docker容器 docker镜像采用分层构建机制,最底层为bootfs,其之为rootfs bootfs: ...
- Docker 学习3 Docker镜像管理基础
一.docker 常用操作及原理 1.docker 常用操作 2.docker 机制 1.docker client端是通过http或者https与server端通信的.个 2.docker 镜像可以 ...
随机推荐
- C# async、await、Task 探讨
test02.ProntOut(); ///*第五题*/ static class test02 { public static async void ProntOut() { Console.Wri ...
- Exception processing template "index": An error happened during template rendering
问题所在 brandList[0].brandId出错,要不就改正,要不就把他删了,注释也会报错.
- 转帖:GitBook 从懵逼到入门
是什么? 在我认识 GitBook 之前,我已经在使用 Git 了,毋容置疑,Git 是目前世界上最先进的分布式版本控制系统. 我认为 Git 不仅是程序员管理代码的工具,它的分布式协作方式同样适 ...
- AreEngine 求最小面积的外接矩形,非IEnvelope,表达不清楚了
1,总是会得到一些奇奇怪怪的要求,求一个面对象的外接最小面积的矩形,和ArcToolBox中的Mininum Bounding Geometry功能下的RECTANGLE_BY_AREA想似.具体看下 ...
- What is Weight Lifting?
Weight lifting is the process of lifting items of great mass in order to increase the muscle size an ...
- CF1732A Bestie
思路 观察数据\(n \le 20\) 直接暴力. 我们直接算所有数的\(GCD\),然后枚举\(1\)~\(n\)的每一个数要不要选,然后选的话,就把原来的\(GCD\)和当前枚举的数\(GCD\) ...
- Double-Checked Locking 双重检查锁问题
Code Correctness: Double-Checked Locking Abstract Double-checked locking 是一种不正确的用法,并不能达到预期目标. Explan ...
- 再谈回声消除测评丨Dev for Dev 专栏
本文为「Dev for Dev 专栏」系列内容,作者为声网音视频实验室工程师 黄译庆. 音频质量的优化是一个复杂的系统工程,回声消除是其中一个老生常谈的话题,一般来说,回声消除的效果受设备本身的声学设 ...
- MySQL长时间不登录密码过期解决办法
MySql管理工具 Navicat for MySql的时候,弹出了一个1862 - MySql Your password has expired.To log in you must change ...
- CTF-RE-学习记录-汇编
八进制运算 加法表 1+1=2 1+2=3 2+2=4 1+3=4 2+3=5 3+3=6 1+4=5 2+4=6 3+4=7 4+4=10 1+5=6 2+5=7 3+5=8 4+5=11 5+5= ...