Is there a way to list all running docker containers by name?

I know how to get a list of "container IDs" of all running docker containers.

$ docker ps -q

+5
source share
4 answers

That should do it. Apologies for the slash at the beginning.

$ docker inspect -f {{.Name}} $(docker ps -q) /test /test2 
+4
source

maybe docker ps | awk 'NR>1 {print $2}' docker ps | awk 'NR>1 {print $2}' NR> 1 avoids the print id for the first line

0
source

I did not find a solution using docker ps , but you can do it using docker-compose (formerly fig ):

docker-compose ps | awk '{print $1}' docker-compose ps | awk '{print $1}' will return something like this:

 Name ------------------------------------------------------------------------------- src_bus_1 src_db_1 src_images_1 src_nginx_1 src_python_1 
0
source
 docker ps | awk 'NR>1 {print $(NF)}' 

doing this

NR>1 avoids printing the header line, and print $(NF) prints the last column of output.

0
source

All Articles