Docker Community Forums

Share and learn in the Docker community.

How was this image instantiated?

docker

(Thufirh) #1

While I can review command history to see the syntax used to instantiate a container image (is that event he correct lingo?), how can I do so from docker itself?

ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              20c44cd7596f        4 days ago          123MB
bash                latest              36a0607f828e        2 weeks ago         12.2MB
hello-world         latest              725dcfab7d63        2 weeks ago         1.84kB
dougbtv/asterisk    latest              482a38f06c9b        2 months ago        1.08GB
jmar71n/freepbx     latest              8dda2a58fde1        19 months ago       1.54GB
ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker image inspect dougbtv/asterisk
[
    {
        "Id": "sha256:482a38f06c9bf7df68318c3b8f9419bb920a7a8ca74ba43c2844af8f4541dab9",
        "RepoTags": [
            "dougbtv/asterisk:latest"
        ],
        "RepoDigests": [
            "dougbtv/asterisk@sha256:875018cc1851285f63b11fa2b083c9362a5d0dc0be7a22ac537ef00d025c0a07"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2017-09-01T18:17:41.324400393Z",
        "Container": "c90c0287aec2c84bd3c94d0e82c69749e65bc729d124f209c193a5e9323dde08",
        "ContainerConfig": {
            "Hostname": "1b0d6163fdc2",
            "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",
                "build_date=2017-09-01",
                "AUTOBUILD_UNIXTIME=1418234402",
                "rebuild_date=2015-05-15"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"/bin/sh\" \"-c\" \"/usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:9346c9b5ae93957b7dc8abf259ccd45ed318447108ed6019ac4b2cf5e2ddd5a5",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {
                "build-date": "20161214",
                "license": "GPLv2",
                "name": "CentOS Base Image",
                "vendor": "CentOS"
            }
        },
        "DockerVersion": "1.12.5",
        "Author": "Doug Smith <info@laboratoryb.org>",
        "Config": {
            "Hostname": "1b0d6163fdc2",
            "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",
                "build_date=2017-09-01",
                "AUTOBUILD_UNIXTIME=1418234402",
                "rebuild_date=2015-05-15"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "/usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:9346c9b5ae93957b7dc8abf259ccd45ed318447108ed6019ac4b2cf5e2ddd5a5",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {
                "build-date": "20161214",
                "license": "GPLv2",
                "name": "CentOS Base Image",
                "vendor": "CentOS"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 1078087607,
        "VirtualSize": 1078087607,
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:34e7b85d83e48a22bd5dfa2b6b9ee9565b7ef672f09b3d2409c61635f9bca4db",
                "sha256:a27e9933e589544b376bd61ff113b12993fdc980bab6551ac8b5f84ff6d95d05",
                "sha256:619c4e807d8592c51524b371d99cc372c70689af50a857617a4bc6b152c0546e",
                "sha256:c70f775f26d1681f52a5b3d74ab3406d5b32e3fcc9e348c095d3a85f48d0d586",
                "sha256:cfa5bf9b961856a7cdbafb9b162285d1dfb720402225b72bf9ed2f9e6a01ca41",
                "sha256:eaf5351ce273f2c016d74ec05c1d7f085d223f0adb6ab04b59c0c1747fa65131",
                "sha256:03c917c95bfb5b1e611934b38f7933d6876b857169497050d4ca9119cd6c820e",
                "sha256:1eb18e1fb934fd26ff777334d746975ed0b1cf043aa840004e6ba1b0f029e36f",
                "sha256:34528ecd5525d36e285ab8e6fe80a402e60fae11163f00e6d170eeea223b7a64",
                "sha256:1f874710c128373de158346c737fc2c4ec590db52864d68818d18f75d4e4d7e3",
                "sha256:64e5b9b6e1aea6753b6ba4d4db15cd1b180393cb9e93c6ef3e190c40f0d38366",
                "sha256:35c22eef460ca2fa7217c8338c0d7b1010abf1bb55e42216062e01b6e5d1ea12",
                "sha256:fe6ea04baf8b280538942f1b2b01fe5b5ff327b379a4a90988264d1e641d693f",
                "sha256:3b25d811bd4ecd1187a0bdc89352e434fcbc191fc2d31366e39cbdf49dcad014",
                "sha256:1e95dd7d25ee3c022bcca848f0ab48e8b969deb626422c83233a30e147474d82",
                "sha256:560e597d4307cc608dd9ea86558be949100bf4ead07a718277c32fe542d25cc6",
                "sha256:d96b73d70916a59de6bbf832dd1cd28fe65151211abb7dcb25af78c6598660f8"
            ]
        }
    }
]
ubuntu@ip-172-31-14-19:~$ 


doesn’t show me how the image was instantiated from the console:

ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ history | grep asterisk_01
  319  sudo docker run --name asterisk_01 --net=host -d -t dougbtv/asterisk
  334  history | grep asterisk_01
ubuntu@ip-172-31-14-19:~$ 


(David Maze) #2

Are you looking for docker history? That will show you the individual steps that went into building an image. (Like docker inspect, it’s kind of an advanced debugging command, though.)

If you’ve started a container with docker run, docker ps will show you some of the key parts that were on the command line (especially the container name and published ports). I’m not aware of a tool that could reconstruct a docker run command line, though you could probably do it (it would be a straightforward exercise using something like the Docker Python client library). Nothing with “image” in its command name is what you’re looking for in this case, though.


(Sam) #3

not quite sure I understand

docker image is a list of the things output from docker build
(there may be intermediate images used during the build)

docker RUN makes a running instance of an image… this is called a container

docker ps shows running containers
docker ps -a shows all ‘containers’ and their states…
docker images shows ‘images’ loaded locally (from docker build or docker pull)