Docker Images history

The size of the Docker Image was suddenly increasing, I will check it. Using docker history <Image name> you can check the change history for Image before. Now, let’s Docker Images history.

Docker Images history

Docker pull command

Requires Image to be downloaded locally. As an example, I use docker pull image centos as below

[vagrant@localhost ~]$ docker pull centos:6.10
6.10: Pulling from library/centos
1c8f9aa56c90: Pull complete
Digest: sha256:b4c3fe75b135ca1c26ef6feb8153aade8a31c4e3e763376529c1088de7e973f4
Status: Downloaded newer image for centos:6.10

[vagrant@localhost ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              6.10                30e66b619e9f        4 months ago        194MB

Try it

The output order is new, and it seems that it becomes an old layer as going down as below

[vagrant@localhost ~]$ docker history centos:6.10
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
30e66b619e9f        4 months ago        /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>           4 months ago        /bin/sh -c #(nop)  LABEL org.label-schema.sc…   0B
<missing>           4 months ago        /bin/sh -c #(nop) ADD file:769078df784180af4…   194MB

Also, With the “–human” option, the actual date is displayed below

[vagrant@localhost ~]$ docker history centos:6.10 --human=false
IMAGE               CREATED AT                  CREATED BY                                      SIZE                COMMENT
30e66b619e9f        2018-10-10T01:22:51+07:00   /bin/sh -c #(nop)  CMD ["/bin/bash"]            0
<missing>           2018-10-10T01:22:51+07:00   /bin/sh -c #(nop)  LABEL org.label-schema.sc…   0
<missing>           2018-10-10T01:22:51+07:00   /bin/sh -c #(nop) ADD file:769078df784180af4…   193889316

Docker inspect container information

Using docker inspect command to Confirmation of container information.

[vagrant@localhost ~]$ docker inspect centos:6.10
[
    {
        "Id": "sha256:30e66b619e9f73941f418bb08a081132607433f5b8ccaefd3b7bceb08c770b20",
        "RepoTags": [
            "centos:6.10"
        ],
        "RepoDigests": [
            "centos@sha256:b4c3fe75b135ca1c26ef6feb8153aade8a31c4e3e763376529c1088de7e973f4"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2018-10-09T18:22:51.586650744Z",
        "Container": "9a31860c3402344acd1f16127fec864b93038c86e8716f08e5dc2a60851a602e",
        "ContainerConfig": {
            "Hostname": "9a31860c3402",
            "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/bash\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:34321cccc68dac29b496363ca05c47e7f23c3e59d664fea4de03695975443b8b",
            "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": "17.06.2-ce",
        "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/bash"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:34321cccc68dac29b496363ca05c47e7f23c3e59d664fea4de03695975443b8b",
            "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": 193889316,
        "VirtualSize": 193889316,
        "GraphDriver": {
            "Data": {
                "MergedDir": "/var/lib/docker/overlay2/f799911e2d9e2de958ee359b6a6e125a93a69992c34851acb63ec1f22e2f9da2/merged",
                "UpperDir": "/var/lib/docker/overlay2/f799911e2d9e2de958ee359b6a6e125a93a69992c34851acb63ec1f22e2f9da2/diff",
                "WorkDir": "/var/lib/docker/overlay2/f799911e2d9e2de958ee359b6a6e125a93a69992c34851acb63ec1f22e2f9da2/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:18c81886066a186e754291bab5ae87b273b274c66c2c9fea8e869a7cb67dac1b"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

Extract only environment variables as below

[vagrant@localhost ~]$ docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' centos:6.10
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Conclusion

Through the article, You can inspect “Docker images history” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.