docker ps --format "table {{.Names}}"
output NAMES
in first row:
root@docker-2gb-blr1-01:~# docker ps --format "table {{.Names}}" NAMES enr osticket osticket_db ...
docker inspect --format '{{.Name}}' $(docker ps -q)
prints /
in the beginning of container name:
root@docker-2gb-blr1-01:~# docker inspect --format '{{.Name}}' $(docker ps -q)" /enr /osticket /osticket_db
I want to list only names of running containers, without header or slash in beginning. Please share options how to do this.
In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command.
docker ps --no-trunc will display the full command along with the other details of the running containers.
The 'docker ps' is a Docker command to list the running containers by default; however, we can use different flags to get the list of other containers that are in stopped or exited status. We can also manipulate the output as per our requirement using flags.
Try removing the table
part from your --format
argument, such as:
docker ps --format '{{.Names}}'
It should give you a simple list of container names with no table heading
Here is how we query the other columns with docker ps
.
Names:
docker ps --format '{{.Names}}'
ID:
docker ps --format '{{.ID}}'
Image:
docker ps --format '{{.Image}}'
Command:
docker ps --format '{{.Command}}'
Created:
docker ps --format '{{.RunningFor}}'
Status:
docker ps --format '{{.Status}}'
Ports:
docker ps --format '{{.Ports}}'
More information can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With