Skip to content

Instantly share code, notes, and snippets.

@Geekfish
Last active January 2, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Geekfish/8f13ab14acb17eceb137e76075de0eda to your computer and use it in GitHub Desktop.
Save Geekfish/8f13ab14acb17eceb137e76075de0eda to your computer and use it in GitHub Desktop.
Inspect mounted volumes in docker containers
docker ps -q | xargs -I '{}' docker inspect {} | jq '.[] | {container_id: .Id, image: .Config.Image, mounts: .Mounts}'
@Geekfish
Copy link
Author

Geekfish commented Jan 2, 2019

Results in something like:

{
  "container_id": "990f8f55610c7841a229944c0c5de4f022cb0bbc5f746d74705c4cf9ad2ee01a",
  "image": "mysql:5.7",
  "mounts": [
    {
      "Type": "bind",
      "Source": "/Users/username/myproject/docker/files/mysql/mysql-init",
      "Destination": "/docker-entrypoint-initdb.d",
      "Mode": "rw",
      "RW": true,
      "Propagation": "rprivate"
    },
    {
      "Type": "bind",
      "Source": "/Users/username/myproject//docker/files/mysql/conf.d",
      "Destination": "/etc/mysql/conf.d",
      "Mode": "rw",
      "RW": true,
      "Propagation": "rprivate"
    },
    {
      "Type": "bind",
      "Source": "/Users/username/myproject//docker/data/mysql",
      "Destination": "/var/lib/mysql",
      "Mode": "rw",
      "RW": true,
      "Propagation": "rprivate"
    }
  ]
}
...

for all active containers.
Amend the docker ps part for inspecting different sets of containers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment