Forrest logo
back to the docker tool

docker:tldr:a0a1f

docker: Filter containers that mount a specific volume or have a volume mounted in a specific path.
$ docker ps --filter="volume=${path-to-directory}" --format "table ${-ID}\t${-Image}\t${-Names}\t${-Mounts}"
try on your machine

This command is using the docker ps command with some additional options and filters to display a tabular output of Docker containers with specific information.

Here is a breakdown of the command:

  • docker ps: This is the main command to list running Docker containers.

  • --filter="volume=${path-to-directory}": This filter option is used to list only the containers that have a specified volume mounted. The path-to-directory should be replaced with the actual path to the directory you want to filter by.

  • --format "table ${-ID}\t${-Image}\t${-Names}\t${-Mounts}": This option is used to specify the output format of the command. The table format is used to display the output in a tabular format. The ${-ID}, ${-Image}, ${-Names}, and ${-Mounts} placeholders are used to specify the columns to be displayed in the table. These placeholders get replaced by the actual values of the container's ID, image, names, and mounts.

So, when you run this command, it will only display the Docker containers that have the specified volume mounted, and for each displayed container, it will show the ID, image, names, and mounts in a tabular format.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool