Post History
You can find that when you run docker inspect $CONTAINER. You can automate this with a simple loop like this: for CONTAINER in $(docker ps -qa); do docker inspect $CONTAINER |grep -q $DIRNAME...
Answer
#2: Post edited
- You can find that when you run `docker inspect $CONTAINER`. You can automate this with a simple loop like this:
- ```bash
- for CONTAINER in $(docker ps -qa);
- do docker inspect $CONTAINER |grep -q $DIRNAME && docker ps -a |grep $CONTAINER;
- done
- ```
- where `$DIRNAME` is the overlay directory name.
This will loop over all containers- Example:
- ```console
- root@host:/var/lib/docker/overlay2# ls -1
- e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35
- root@host:/var/lib/docker/overlay2# for CONTAINER in $(docker ps -qa); do docker inspect $CONTAINER |grep -q e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35 && docker ps -a |grep $CONTAINER; done
- 458f26e907ff wordpress "docker-entrypoint.s…" 11 months ago Up 12 days 0.0.0.0:8081->80/tcp, [::]:8081->80/tcp wordpress-wordpress-1
- ```
- You can find that when you run `docker inspect $CONTAINER`. You can automate this with a simple loop like this:
- ```bash
- for CONTAINER in $(docker ps -qa);
- do docker inspect $CONTAINER |grep -q $DIRNAME && docker ps -a |grep $CONTAINER;
- done
- ```
- where `$DIRNAME` is the overlay directory name.
- This will loop over all containers, grep the output of `docker inspect` on it and if it finds the directory name it will run `grep` with the container ID on the output of `docker ps -a`, showing the container where it is mounted.
- If you don't get any output the container where it belonged to doesn't exist anymore.
- Example:
- ```console
- root@host:/var/lib/docker/overlay2# ls -1
- e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35
- root@host:/var/lib/docker/overlay2# for CONTAINER in $(docker ps -qa); do docker inspect $CONTAINER |grep -q e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35 && docker ps -a |grep $CONTAINER; done
- 458f26e907ff wordpress "docker-entrypoint.s…" 11 months ago Up 12 days 0.0.0.0:8081->80/tcp, [::]:8081->80/tcp wordpress-wordpress-1
- ```
#1: Initial revision
You can find that when you run `docker inspect $CONTAINER`. You can automate this with a simple loop like this: ```bash for CONTAINER in $(docker ps -qa); do docker inspect $CONTAINER |grep -q $DIRNAME && docker ps -a |grep $CONTAINER; done ``` where `$DIRNAME` is the overlay directory name. This will loop over all containers Example: ```console root@host:/var/lib/docker/overlay2# ls -1 e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35 root@host:/var/lib/docker/overlay2# for CONTAINER in $(docker ps -qa); do docker inspect $CONTAINER |grep -q e9341f72f22128ceeed7373a36bce28d02751bd0c51e60e1deaa8f77903f2f35 && docker ps -a |grep $CONTAINER; done 458f26e907ff wordpress "docker-entrypoint.s…" 11 months ago Up 12 days 0.0.0.0:8081->80/tcp, [::]:8081->80/tcp wordpress-wordpress-1 ```