When I ran docker ps -a
, I got
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e3be2faeb751 centos:latest touch /var/log/test 2 minutes ago Exited (1) 2 minutes ago insane_kirch6
What is the name, insane_kirch6, for?
Not only for visibility, but it also can be used as
container_id
in theexec
orrm
command.When you want to run a command in an existing container (running or exited), you will use the "docker exec" command in which you specify the container name or id.
Examples:
Create a container named qqqq and start a process "sleep" 1 minutes, and then exit.
Run another command in the container qqqq:
Delete the container qqqq:
And even more importantly, you can run named containers again later with
start
:You can name your own containers with
--name
when you usedocker run
. If you do not provide a name, Docker will generate a random one like the one you have.Check their documentation for naming at Legacy container links, The importance of naming