Languages
[Edit]
EN

Docker - get container name

3 points
Created by:
isherwood
239

Quick solutions:

# last column of docker ps command contains container names
docker ps

# print only container names
docker ps --format "{{.Names}}"

 

Practical examples:

The last column is the name of the container. 

docker ps

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

If we want to get only names without any additional information:

docker ps --format "{{.Names}}"

# Above command will print only docker container names
# In my case 2 containers:

webapp
redis,webapp/db

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join