Hello,
I have a few container and volumes, how can I know what volumes belong to what container?
thanks.
Share and learn in the Docker community.
Hello,
I have a few container and volumes, how can I know what volumes belong to what container?
thanks.
hey
use docker inspect <container name or id>
then check Mounts section, it contains all the volume attached to that container
Hello,
This is the info I get
},
āMountsā: ,
āConfigā: {
āHostnameā: ā6282d7693e03ā,
āDomainnameā: āā,
āUserā: āā,
āAttachStdinā: true,
āAttachStdoutā: true,
āAttachStderrā: true,
āTtyā: true,
āOpenStdinā: true,
āStdinOnceā: true,
āEnvā: [
āPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binā
],
āCmdā: [
ā/bin/bashā
],
āImageā: āmax.v3ā,
āVolumesā: null,
āWorkingDirā: āā,
āEntrypointā: null,
āOnBuildā: null,
āLabelsā: {
ābuild-dateā: ā20161214ā,
"license": "GPLv2",
"name": "CentOS Base Image",
"vendor": "CentOS"
}
sudo docker volume list
DRIVER VOLUME NAME
local 45f231398741c24982db2db0061cb202ec6ac07229d63e7261a6ed987698872c
local 556d23b33ee2862af7bae27939e08445ac2d38898d02f74eb838c79f7539435c
local 582eae6c59c18b16ce5228d71be088171c3aaaa70ef28a4b0fd5fe39457ade68
local dbf84dd0f1242078ced712fe4d2a8620667c4304e74ef80bb2df2780efd7ad6b
local e55f8b5d5313041adf7fd381da24934c648518538b393272d90a19714111d731
hey
Mounts section should show like below if anything attached
Mounts: [ { "Type": "volume", "Name": "c04f04a571d3e44ec6d6b5f89641f4f518a30c80916e026e8f18b7616165f2e8", "Source": "/var/lib/docker/volumes/c04f04a571d3e44ec6d6b5f89641f4f518a30c80916e026e8f18b7616165f2e8/_data", "Destination": "/data", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ]
if not that means no volume is attached
Thanks.!!! I will try to understand a little more about this.
welcome 
please do post if you find interesting.
The following snippet will tell you the IP of a container. Use the same logic to get details about the volume
docker inspect -f ā{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}ā CONTAINER_NAME_OR_ID