在CSDN找到一篇总结Docker操作方法的文章,写的很好,一直在用他教的命令,我就搬运过来。

本教程包含:
Docker 镜像管理,显示本地镜像,查找镜像,删除镜像,镜像拉取,查看镜像的具体信息,镜像的导入和导出,将配置后的镜像commit成自己的镜像,docker history,等。

显示本地镜像

[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              c82521676580        3 weeks ago         109MB
[[email protected] ~]#

镜像查找

[[email protected] ~]# docker search nginx
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                                                  Official build of Nginx.                        9300                [OK]                
jwilder/nginx-proxy                                    Automated Nginx reverse proxy for docker con…   1384                                    [OK]
richarvey/nginx-php-fpm                                Container running Nginx + PHP-FPM capable of…   610                                     [OK]
jrcs/letsencrypt-nginx-proxy-companion                 LetsEncrypt container to use with nginx as p…   394                                     [OK]
kong                                                   Open-source Microservice & API Management la…   215                 [OK]                
webdevops/php-nginx                                    Nginx with PHP-FPM                              111                                     [OK]
kitematic/hello-world-nginx                            A light-weight nginx container that demonstr…   108                                     
zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server wi…   62                                      [OK]
bitnami/nginx                                          Bitnami nginx Docker Image                      57                                      [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          43                                      [OK]
linuxserver/nginx                                      An Nginx container, brought to you by LinuxS…   38                                      
tobi312/rpi-nginx                                      NGINX on Raspberry Pi / armhf                   20                                      [OK]
blacklabelops/nginx                                    Dockerized Nginx Reverse Proxy Server.          12                                      [OK]
nginxdemos/nginx-ingress                               NGINX Ingress Controller for Kubernetes . Th…   11                                      
wodby/drupal-nginx                                     Nginx for Drupal container image                10                                      [OK]
webdevops/nginx                                        Nginx container                                 8                                       [OK]
nginxdemos/hello                                       NGINX webserver that serves a simple page co…   8                                       [OK]
centos/nginx-18-centos7                                Platform for running nginx 1.8 or building n…   7                                       
1science/nginx                                         Nginx Docker images that include Consul Temp…   4                                       [OK]
centos/nginx-112-centos7                               Platform for running nginx 1.12 or building …   4                                       
pebbletech/nginx-proxy                                 nginx-proxy sets up a container running ngin…   2                                       [OK]
travix/nginx                                           NGinx reverse proxy                             1                                       [OK]
toccoag/openshift-nginx                                Nginx reverse proxy for Nice running on same…   1                                       [OK]
ansibleplaybookbundle/nginx-apb                        An APB to deploy NGINX                          0                                       [OK]
mailu/nginx                                            Mailu nginx frontend                            0                                       [OK]
[[email protected] ~]#

镜像删除

Docker rmi image id (当容器存在的时候删不掉,应该先删除镜像再删除容器)

[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
cf05d1459d71        nginx               "nginx -g 'daemon of…"   9 hours ago         Up 9 hours          0.0.0.0:32768->80/tcp   serene_boyd
[[email protected] ~]# docker stop cf05d1459d71
cf05d1459d71
[[email protected] ~]# docker rm cf05d1459d71
cf05d1459d71
[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              c82521676580        3 weeks ago         109MB
[[email protected] ~]# docker rmi c82521676580
Untagged: nginx:latest
Untagged: [email protected]:4ffd9758ea9ea360fd87d0cee7a2d1cf9dba630bb57ca36b3108dcd3708dc189
Deleted: sha256:c82521676580c4850bb8f0d72e47390a50d60c8ffe44d623ce57be521bca9869
Deleted: sha256:2c1f65d17acf8759019a5eb86cc20fb8f8a7e84d2b541b795c1579c4f202a458
Deleted: sha256:8f222b457ca67d7e68c3a8101d6509ab89d1aad6d399bf5b3c93494bbf876407
Deleted: sha256:cdb3f9544e4c61d45da1ea44f7d92386639a052c620d1550376f22f5b46981af
[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[[email protected] ~]#

镜像拉取和推送

Docker pull 即可

查看镜像的具体信息

[[email protected] mnt]# docker inspect f3c5dcc79825 ##可以看到相关具体配置,和镜像分层。

[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                   NAMES
e1cfa12a7593        nginx               "nginx -g 'daemon of…"   About a minute ago   Up About a minute   0.0.0.0:32769->80/tcp   sharp_jepsen
[[email protected] ~]# docker inspect e1cfa12a7593
[
    {
        "Id": "e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac",
        "Created": "2018-08-18T13:13:09.592242655Z",
        "Path": "nginx",
        "Args": [
            "-g",
            "daemon off;"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 41600,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-08-18T13:13:09.890319999Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:c82521676580c4850bb8f0d72e47390a50d60c8ffe44d623ce57be521bca9869",
        "ResolvConfPath": "/var/lib/docker/containers/e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac/hostname",
        "HostsPath": "/var/lib/docker/containers/e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac/hosts",
        "LogPath": "/var/lib/docker/containers/e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac/e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac-json.log",
        "Name": "/sharp_jepsen",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": true,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/asound",
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/90ede5148ae500a2ee42503f51af05e55ea2ff94f26cb5a107e20c2ad2202eb7-init/diff:/var/lib/docker/overlay2/4516eac9778ec4fe0587bda00a24b83a02bbe1511239659b787d6e493b679ca2/diff:/var/lib/docker/overlay2/476ea1f5c87e512f0730756f803fd8a4f7c987d993727410735db154a2191514/diff:/var/lib/docker/overlay2/7d34ec852a0643fca9a0999a218f142558b3ce7736587bccbc8a0d6063791ccb/diff",
                "MergedDir": "/var/lib/docker/overlay2/90ede5148ae500a2ee42503f51af05e55ea2ff94f26cb5a107e20c2ad2202eb7/merged",
                "UpperDir": "/var/lib/docker/overlay2/90ede5148ae500a2ee42503f51af05e55ea2ff94f26cb5a107e20c2ad2202eb7/diff",
                "WorkDir": "/var/lib/docker/overlay2/90ede5148ae500a2ee42503f51af05e55ea2ff94f26cb5a107e20c2ad2202eb7/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "e1cfa12a7593",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.15.2-1~stretch",
                "NJS_VERSION=1.15.2.0.2.2-1~stretch"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "ArgsEscaped": true,
            "Image": "nginx",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <[email protected]>"
            },
            "StopSignal": "SIGTERM"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "16293dc84e08e6aed7360690919cab9912ffed115a1d2a932aace37e3c123721",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32769"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/16293dc84e08",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "01430c1e53c278d140e6e51e37ee9d1d0ad232059e808b55071e363828563e71",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "c893f56aef621becaecce35f131cd25e660183a001f19a435e9004ec9a2df15f",
                    "EndpointID": "01430c1e53c278d140e6e51e37ee9d1d0ad232059e808b55071e363828563e71",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]
[[email protected] ~]#

运行一个容器

[[email protected] ~]# docker run -dit -P nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
be8881be8156: Pull complete 
32d9726baeef: Pull complete 
87e5e6f71297: Pull complete 
Digest: sha256:d85914d547a6c92faa39ce7058bd7529baacab7e0cd4255442b04577c4d1f424
Status: Downloaded newer image for nginx:latest
e1cfa12a7593e43e539b4b06b96fffe81a672126344691ed8a27699b36e395ac
[[email protected] ~]# 
–name ##容器名称
–link ##连接某个镜像
–port ##端口映射
–volum ##持久化存储

镜像的导入导出

[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
e1cfa12a7593        nginx               "nginx -g 'daemon of…"   3 minutes ago       Up 2 minutes        0.0.0.0:32769->80/tcp   sharp_jepsen
#将上面镜像名称为nginx的镜像保存到mynginx.tar这个包中
[[email protected] ~]# docker save -o mynginx.tar e1cfa12a7593
Error response from daemon: No such image: e1cfa12a7593
[[email protected] ~]# docker save -o mynginx.tar nginx
[[email protected] ~]# ll
-rw-------  1 root root  112703488 8月  18 21:19 mynginx.tar
[[email protected] ~]# ls | grep myngi
mynginx.tar
[[email protected] ~]#

发现上面已经有了一个mynginx.tar的包

复制到另一台机器上导入(接下来是机器192.168.106.110机器,上面是109机器):

[[email protected] ~]# pwd
/root
[[email protected] ~]# ll
-rw-r--r--  1 root root 112703488 8月  18 21:31 mynginx.tar
[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[[email protected] ~]# docker load < mynginx.tar 
cdb3f9544e4c: Loading layer [==================================================>]  58.44MB/58.44MB
a8c4aeeaa045: Loading layer [==================================================>]  54.24MB/54.24MB
08d25fa0442e: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: nginx:latest
[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              c82521676580        3 weeks ago         109MB
[[email protected] ~]#

通过上面我们可以看到开始docker images中没有镜像列表,在导入之后发现多了一个镜像.

创建一个已经存在的镜像ID然后用commit提交

1.启动一个镜像,然后创建一个叫toto的文件,然后退出

[[email protected] ~]# docker run -itd centos /bin/bash
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
256b176beaff: Pull complete 
Digest: sha256:5d91c5535c41fd1bb48d40581a2c8b53d38fc2eb26df774556b53c5a0bd4d44e
Status: Downloaded newer image for centos:latest
dfd1c30384f1fe8250a9516b4b204e553c8eb23b22beec6823a99721a8eeadd3
[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
dfd1c30384f1        centos              "/bin/bash"              8 seconds ago       Up 8 seconds                                ecstatic_booth
e1cfa12a7593        nginx               "nginx -g 'daemon of…"   22 minutes ago      Up 22 minutes       0.0.0.0:32769->80/tcp   sharp_jepsen
[[email protected] ~]# docker attach dfd1c30384f1
[[email protected] /]# echo "toto" > tuzuoquan.txt
[[email protected] /]# ll
total 16
-rw-r--r--   1 root root 12005 Aug  4 22:05 anaconda-post.log
lrwxrwxrwx   1 root root     7 Aug  4 22:04 bin -> usr/bin
drwxr-xr-x   5 root root   360 Aug 18 13:35 dev
drwxr-xr-x   1 root root    66 Aug 18 13:35 etc
drwxr-xr-x   2 root root     6 Apr 11 04:59 home
lrwxrwxrwx   1 root root     7 Aug  4 22:04 lib -> usr/lib
lrwxrwxrwx   1 root root     9 Aug  4 22:04 lib64 -> usr/lib64
drwxr-xr-x   2 root root     6 Apr 11 04:59 media
drwxr-xr-x   2 root root     6 Apr 11 04:59 mnt
drwxr-xr-x   2 root root     6 Apr 11 04:59 opt
dr-xr-xr-x 151 root root     0 Aug 18 13:35 proc
dr-xr-x---   2 root root   114 Aug  4 22:05 root
drwxr-xr-x  10 root root   130 Aug  4 22:05 run
lrwxrwxrwx   1 root root     8 Aug  4 22:04 sbin -> usr/sbin
drwxr-xr-x   2 root root     6 Apr 11 04:59 srv
dr-xr-xr-x  13 root root     0 Apr 11 04:59 sys
drwxrwxrwt   7 root root   132 Aug  4 22:05 tmp
-rw-r--r--   1 root root     5 Aug 18 13:36 tuzuoquan.txt
drwxr-xr-x  13 root root   155 Aug  4 22:04 usr
drwxr-xr-x  18 root root   238 Aug  4 22:04 var
[[email protected] /]# exit
exit
[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                     PORTS                   NAMES
dfd1c30384f1        centos              "/bin/bash"              About a minute ago   Exited (0) 4 seconds ago                           ecstatic_booth
e1cfa12a7593        nginx               "nginx -g 'daemon of…"   24 minutes ago       Up 24 minutes              0.0.0.0:32769->80/tcp   sharp_jepsen
[[email protected] ~]#

2.用commit 提交相关镜像生成一个新镜像

[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                     PORTS                   NAMES
dfd1c30384f1        centos              "/bin/bash"              About a minute ago   Exited (0) 4 seconds ago                           ecstatic_booth
e1cfa12a7593        nginx               "nginx -g 'daemon of…"   24 minutes ago       Up 24 minutes              0.0.0.0:32769->80/tcp   sharp_jepsen
[[email protected] ~]# docker commit -m "Add tuzuoquan.txt" -a "toto-txt" dfd1c30384f1 toto
sha256:232eab347b5b848ef4484b47e912515b53b5f75af4d3ae507a0af6e42f10a46d
-m:表示备注信息
-a:作者相关信息。
dfd1c30384f1:就是刚刚我们创建的容器ID
toto: 表示生成的镜像名称

3.然后生成了这个镜像

[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
toto                latest              232eab347b5b        About a minute ago   200MB
centos              latest              5182e96772bf        11 days ago          200MB
nginx               latest              c82521676580        3 weeks ago          109MB
[[email protected] ~]#

4.我们可以查看 那个文件内容是否是toto呢

[[email protected] ~]# docker run toto cat tuzuoquan.txt
toto
[[email protected] ~]#

当然我们不推荐这种方式,应该使用Dockerfile来操作的。后面才讲。

我们之前认证过,镜像由于是基于unfs联合文件系统,所以镜像是一个leyer的层级来存储的。在刚刚上面的镜像当中,我们给镜像添加了一个Add tuzuoquan.txt的文件层,我们来验证一下:

1.我们可以看到分别有一下三层layer构成了当前的toto镜像

[[email protected] ~]# docker history toto
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
232eab347b5b        About an hour ago   /bin/bash                                       41B                 Add tuzuoquan.txt
5182e96772bf        11 days ago         /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B                  
<missing>           11 days ago         /bin/sh -c #(nop)  LABEL org.label-schema.sc…   0B                  
<missing>           11 days ago         /bin/sh -c #(nop) ADD file:6340c690b08865d7e…   200MB               
[[email protected] ~]# 

2.查看本地文件一探究竟

[[email protected] ~]# cd /var/lib/docker/
[[email protected] docker]# ll
total 8
drwx------. 20 root root 4096 Mar 12 17:11 containers      ##容器运行相关信息
drwx------.  5 root root   50 Dec 17 22:59 devicemapper    ##存储对应的存储池和相关的元数据
drwx------.  3 root root   25 Dec 17 22:52 image           ##各层相关信息
drwxr-x---.  3 root root   18 Dec 17 22:52 network         
drwx------   4 root root   30 Feb 21 14:26 plugins
drwx------.  2 root root    6 Dec 19 11:54 swarm
drwx------.  5 root root   96 Mar 12 16:57 tmp
drwx------.  2 root root    6 Dec 17 22:52 trust
drwx------. 15 root root 4096 Mar  3 00:45 volumes        ##数据卷相关信息

3.我们也可以查看相关信息

[[email protected] docker]# docker inspect toto
[
    {
        "Id": "sha256:232eab347b5b848ef4484b47e912515b53b5f75af4d3ae507a0af6e42f10a46d",
        "RepoTags": [
            "toto:latest"
        ],
        "RepoDigests": [],
        "Parent": "sha256:5182e96772bf11f4b912658e265dfe0db8bd314475443b6434ea708784192892",
        "Comment": "Add tuzuoquan.txt",
        "Created": "2018-08-18T13:38:10.311466855Z",
        "Container": "dfd1c30384f1fe8250a9516b4b204e553c8eb23b22beec6823a99721a8eeadd3",
        "ContainerConfig": {
            "Hostname": "dfd1c30384f1",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20180804",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "DockerVersion": "18.06.0-ce",
        "Author": "toto-txt",
        "Config": {
            "Hostname": "dfd1c30384f1",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20180804",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 199723865,
        "VirtualSize": 199723865,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/3836d6c8daf0ca0f48d2df7d7ed03d4403f2c604ab7466195228010f14c32016/diff",
                "MergedDir": "/var/lib/docker/overlay2/0ad86a1a99ea0e96430a0300febe1eb0cc81854fdeb9200c9f71a63a86fcfe68/merged",
                "UpperDir": "/var/lib/docker/overlay2/0ad86a1a99ea0e96430a0300febe1eb0cc81854fdeb9200c9f71a63a86fcfe68/diff",
                "WorkDir": "/var/lib/docker/overlay2/0ad86a1a99ea0e96430a0300febe1eb0cc81854fdeb9200c9f71a63a86fcfe68/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:1d31b5806ba40b5f67bde96f18a181668348934a44c9253b420d5f04cfb4e37a",
                "sha256:a06503759f77739def82abb57fd6183881e7f475660d1238c100dad18e46f7f7"
            ]
        },
        "Metadata": {
            "LastTagTime": "2018-08-18T21:38:10.33240725+08:00"
        }
    }
]
[[email protected] docker]#

我们通过层级ID可以看到rootfs的相关信息


参考:
Docker 镜像管理,显示本地镜像,查找镜像,删除镜像,镜像拉取,查看镜像的具体信息,镜像的导入和导出,将配置后的镜像commit成自己的镜像,docker history,等

最后修改:2020 年 02 月 28 日 07 : 26 PM