abhishek
abhishek

Reputation: 143

What does COMMAND label means in docker container list?

I am just starting with docker and I have a silly question. When you list all the containers, you'll see an output like this:

CONTAINER ID        IMAGE                        COMMAND                CREATED              STATUS              PORTS               NAMES
4c01db0b339c        ubuntu:12.04                 bash                   17 seconds ago       Up 16 seconds       3300-3310/tcp       webapp
d7886598dbe2        crosbymichael/redis:latest   /redis-server --dir    33 minutes ago       Up 33 minutes       6379/tcp            redis,webapp/db

I am wondering what does the COMMAND here signifies? Does it mean the last command run by the container or the first one or something else?

I tried the official docker documentation but couldn't find my answer. Any help?

Upvotes: 1

Views: 126

Answers (1)

kstromeiraos
kstromeiraos

Reputation: 5037

COMMAND is the command executed by the container by default when it's started.

When a container is started, a main command is executed, and the container will live until that command finishs. That CMD will be PID 1 inside the container.

In a Dockerfile you specify that command by CMD instruction.

Also, I recommend you to take a look to this thread to be aware of the difference between CMD and ENTRYPOINT: What is the difference between CMD and ENTRYPOINT in a Dockerfile?

Upvotes: 4

Related Questions