Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the name column of the docker ps -a always different

I was just playing around with docker!!

Ran ps command -a option

docker run -a
C:\Users\sarkan1>docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
3d6db385321c        busybox:1.24        "sleep 1000"        26 seconds ago      Up 24 seconds                                   lucid_ramanujan
e6acd65398b2        hello-world         "/hello"            43 minutes ago      Exited (0) 43 minutes ago                       nifty_brattain
c5576137580d        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           dreamy_aryabhata
2594fbf1fa82        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           nostalgic_hopper
c0102bc64c45        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           vibrant_khorana
c4af79ea96e9        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           cranky_heyrovsky

Questions :

  1. Why did I get the values in the names column always different? I ran the same container I guess!!

  2. What is command column? Does the slash before the hello (/hello) have any significance?

like image 572
Nilotpal Avatar asked Jan 28 '18 07:01

Nilotpal


2 Answers

Unless you launch a container specifying its name (docker run --name), docker will generate one for you.
That is easier than referencing said container with its ID.

You can then make docker commands with its (generated) name instead.

See more at "How does Docker generate default container names?".
(and the source code: moby/moby pkg/namesgenerator/names-generator.go)

The command column is the full command executed by the container: once this command stops, the container stops.
That command is specified in the docker image, and is a combination of:

  • Dockerfile ENTRYPOINT
  • Dockerfile CMD

(See "difference between cmd and entrypoint in dockefile")

like image 174
VonC Avatar answered Nov 16 '22 01:11

VonC


Basically they are random container names generated!! The left and right parts of the names are hardcoded and can be found in

https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go

Docker engine generates it if default name is not provided when you create a new docker container.

like image 32
Nilotpal Avatar answered Nov 16 '22 00:11

Nilotpal