Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker volume inspect doesn't show connected containers. #31436

Open
intesar opened this issue Feb 28, 2017 · 9 comments
Open

docker volume inspect doesn't show connected containers. #31436

intesar opened this issue Feb 28, 2017 · 9 comments
Labels
area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.13

Comments

@intesar
Copy link

intesar commented Feb 28, 2017

Description

Steps to reproduce the issue:

  1. docker volume -d local local-100
  2. docker run -d -v local-100:/opt/ nginx:latest
  3. docker volume inspect local-100

Describe the results you received:
missing attached containers.
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/local-100/_data",
"Name": "local-100",
"Options": {},
"Scope": "local"
}
]

Describe the results you expected:
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/local-100/_data",
"Name": "local-100",
"Containers": []
"Options": {},
"Scope": "local"
}
]

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:42:29 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:42:29 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 6
 Running: 5
 Paused: 0
 Stopped: 1
Images: 62
Server Version: 1.13.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 315
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 apparmor
Kernel Version: 4.4.0-51-generic
Operating System: Ubuntu 14.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.945 GiB
Name: dchq-gak
ID: 2MMO:IKKV:QTKW:SS3E:E5MY:7IIV:PBAV:PWDE:BMV5:FMG5:PG44:AQ2S
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: hypergrid
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

@thaJeztah
Copy link
Member

Can you describe the use case for this?

You can do the opposite; to get a list of containers that use a specific volume, use docker ps --filter=volume=<name of volume>, see https://docs.docker.com/engine/reference/commandline/ps/#volume

@thaJeztah thaJeztah added area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Feb 28, 2017
@intesar
Copy link
Author

intesar commented Feb 28, 2017

This is similar to 'docker network inspect bridge'.
Also, docker should block docker volume rm if a container is using the volume.

@thaJeztah
Copy link
Member

Also, docker should block docker volume rm if a container is using the volume

It should do so; did you have a situation where it allowed you to delete a volume that was in use?

@intesar
Copy link
Author

intesar commented Mar 1, 2017

I can delete a volume which in use. e.g. docker volume rm -f local-100.
But there is no way of deleting network which is in use unless I stop the container.

Shouldn't the same behavior be applied to volumes?

@cpuguy83
Copy link
Member

cpuguy83 commented Mar 1, 2017

Yes, -f should not allow the removal of a volume that is in use, that's a bug.
-f is pretty much to handle misbehaving drivers.

@mbentley
Copy link
Contributor

mbentley commented Apr 5, 2017

A use case to be able to see which containers are connected to a volume would be to audit who is accessing what information without having to perform an expensive operation of inspecting every container.

@jcrben
Copy link

jcrben commented Dec 3, 2017

@mbentley you can do that with docker ps --filter volume=<name of volume> - at least, it seems to work well for me

@foresmac
Copy link

True, you can do it that way, but it's not particularly intuitive when there's a command to "inspect" volumes that could just give you the relevant information.

@kumaran85
Copy link

docker ps --filter volume= it worked for me.

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.13
Projects
None yet
Development

No branches or pull requests

8 participants