I am writing a bash script and I am aware that I can get information of the mounts attached to a container using docker inspect --format '{{.Mounts}}' <container-name> which gives a result such as this:
[{volume portainer-data /docker/portainer/data /data local-persist rw true } {bind /var/run/docker.sock /var/run/docker.sock rw true rprivate}]
which is an abbreviated version of the full JSON:
"Mounts": [ { "Type": "volume", "Name": "portainer-data", "Source": "/docker/portainer/data", "Destination": "/data", "Driver": "local-persist", "Mode": "rw", "RW": true, "Propagation": "" }, { "Type": "bind", "Source": "/var/run/docker.sock", "Destination": "/var/run/docker.sock", "Mode": "rw", "RW": true, "Propagation": "rprivate" } ], How can I get that information so that I could check the Type and then use the Name (or any of the other values)?
I've tried docker inspect --format '{{.Mounts}}{{.Type}}' but it doesn't work however a similar command docker ps --format '{{.ID}}: {{ .Mounts }}' prints the container name and the mounts.