EN
Docker - get container name
3 points
Quick solutions:
xxxxxxxxxx
1
# last column of docker ps command contains container names
2
docker ps
3
4
# print only container names
5
docker ps --format "{{.Names}}"
The last column is the name of the container.
xxxxxxxxxx
1
docker ps
2
3
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4
4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds 3300-3310/tcp webapp
5
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:
xxxxxxxxxx
1
docker ps --format "{{.Names}}"
2
3
# Above command will print only docker container names
4
# In my case 2 containers:
5
6
webapp
7
redis,webapp/db