Intro

November 11, 2021 - Reading time: 3 minutes

Running your first container:

test@localhost: sudo docker run dockerinaction/hello_world
Unable to find image 'dockerinaction/hello_world:latest' locally
latest: Pulling from dockerinaction/hello_world
a3ed95caeb02: Pull complete
1db09adb5ddd: Pull complete
Digest: sha256:cfebf86139a3b21797765a3960e13dee000bcf332be0be529858fca840c00d7f
Status: Downloaded newer image for dockerinaction/hello_world:latest
hello world

After printing the message (program stopped), the container is marked as stopped.

Container after creation (not running)

test@localhost: sudo docker container ls --all
CONTAINER ID   IMAGE                        COMMAND                CREATED          STATUS                      PORTS     NAMES
d873f76c1a3c   dockerinaction/hello_world   "echo 'hello world'"   19 minutes ago   Exited (0) 19 minutes ago             modest_sutherland
test@localhost:

Running the container multiple times creates multiple instances

test@localhost: sudo docker container ls --all
CONTAINER ID   IMAGE                        COMMAND                CREATED          STATUS                      PORTS     NAMES
4658622f1268   dockerinaction/hello_world   "echo 'hello world'"   10 seconds ago   Exited (0) 9 seconds ago              relaxed_chandrasekhar
4156ce5490cc   dockerinaction/hello_world   "echo 'hello world'"   11 seconds ago   Exited (0) 10 seconds ago             upbeat_merkle
31c858003d28   dockerinaction/hello_world   "echo 'hello world'"   12 seconds ago   Exited (0) 11 seconds ago             kind_cartwright
df3224150c4b   dockerinaction/hello_world   "echo 'hello world'"   14 seconds ago   Exited (0) 14 seconds ago             zen_satoshi
d873f76c1a3c   dockerinaction/hello_world   "echo 'hello world'"   49 minutes ago   Exited (0) 49 minutes ago             modest_sutherland

Image used to run the container:

test@localhost: sudo docker images
REPOSITORY                   TAG       IMAGE ID       CREATED       SIZE
dockerinaction/hello_world   latest    a1a9a5ed65e9   6 years ago   2.43MB

History / details of the image:

test@localhost: sudo docker image history a1a9a5ed65e9
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
a1a9a5ed65e9   6 years ago   /bin/sh -c #(nop) CMD ["echo" "hello world"]    0B
<missing>      6 years ago   /bin/sh -c #(nop) CMD ["/bin/sh"]               0B
<missing>      6 years ago   /bin/sh -c #(nop) ADD file:f398243fc9cb933fa…   2.43MB
<missing>      6 years ago   /bin/sh -c #(nop) MAINTAINER Jérôme Petazzon…   0B

Image details:

test@localhost: sudo docker image inspect a1a9a5ed65e9 | jq '.[].Config'
{
  "Hostname": "04b9901f18ea",
  "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": [
    "echo",
    "hello world"
  ],
  "Image": "0f864637f229eee9da53fd5591fb58138b6bfb0196f0ee4fd9417d3655fb3d28",
  "Volumes": null,
  "WorkingDir": "",
  "Entrypoint": null,
  "OnBuild": [],
  "Labels": null
}