docker query the container id of the specified name
1. To query the Docker container ID with the specified name
The following commands can be used:
docker ps -aqf "name=CONTAINER_NAME"
2. Among them
-
CONTAINER_NAME
is the name of the container to be queryed.
3. This command will return the container ID with the specified name
Please note:
- If there are multiple containers with the same name
- Then the command will return the IDs of all these containers
4. Explain the various options of the command
-
ps
: List running containers. -
-a
: List all containers (including stopped containers). -
-q
: Show only the container ID. -
-f
: Filter the output according to filter conditions. -
"name=CONTAINER_NAME"
: Filter condition, matching the container with the specified name.
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.