-
Notifications
You must be signed in to change notification settings - Fork 18.9k
docker-inspect: Extend docker inspect to export image metadata related to graph driver #13198
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
Conversation
|
I agree that long term, docker volumes or libgraphdriver are the right solution, but we need something now. |
|
I just mounted an image and then tried deleting it using docker. Deletion succeeded. Actual thin device and associated metadata file deletion failed in graph driver but top layers do not care for the error code. Side affect of this is that when you try to pull delete image again, it fails as graph driver metadata file with same id still exists. And one needs to first delete that file. I am thinking that how about extending this to containers and allow directly mounting container roots. That way we could quickly do following.
Now one should not be able to delete an image as container is using it. And container deletion will fail as device is already mounted. I have already cleaned up the container deletion path so that we will end up with a "Dead" container if container deletion fails. At least for this use case, this should be relatively race free path. |
|
Another advantage of first creating a container and mounting it is that it can be mounted read/write without any risk of any accidental changes ever showing up in image. So it is safer that way too. |
Isn't this a bug? return graph.driver.Remove(id) Or doesn't this return an error? |
|
graph.driver.Remove() does return an error. Yes it is a bug. Just that I am not sure how would you fix this bug. In an image deletion there are so many things which can go wrong. As we don't have the notion of rollback, if error happens on any step, we are in a bad state. We need something like an image state, like containers where we can mark image as "Dead". So that one can try to clean it up later but nobody can launch a container using that image. |
24962d8 to
6f8838a
Compare
|
Refreshed the patch. This time also exported graphdriver data for containers. Now same graphdriver data should be available both for images and containers using docker inspect. |
|
For the curious, I am writing some poof of concept scripts here to mount/unmount docker images. |
|
@crosbymichael ping. How do I make progress on this pull request. Can we reach some sort of conclusion on this? |
|
not sure what to say about the windows CI. It's failed 3 different ways for 3 rebuilds. |
|
docker folks please have a look at this pull request. I think it is a very reasonable addition and allows us to take this metadata information about images/containers and build more tools on top. (mount/unmount). I don't want it to miss 1.7 release window. |
|
We really want to move forward on this, since we need an easy way to examine containers for vulnerabilities. |
|
I am working on a vulnerability scanner for containers ... I have been testing this patch with the git repo and it works as expected. |
6f8838a to
0cd05fa
Compare
|
Refreshed the patch one more time. This time made use of interface{} for graph driver data. That way I can easily access data using docker templates. Ex. docker inspect --format='{{.GraphDriver.Name}}' fedora |
|
@tiborvass @icecrime can we please review this? I really thought there would be a feedback for the 1.7 release :-\ |
|
To speed up the process; IIUC, this adds extra information to the output of also ping @jfrazelle; she likes cherry-picking :-) |
0cd05fa to
71da693
Compare
|
@thaJeztah updated the patch and updated the docker-inspect man page. @jfrazelle can you have a look at this one. |
|
@rhvgoyal In general, it's a bad practice to use |
|
This is not going into 1.7. It's passed the feature freeze, sorry about that. |
|
Different backend can return different type of information. So may be instead of interface{} I can force them to return a map[string]string. And then graph drivers can decide what strings they want to return. (like docker info). Will that work? I wished this had got some attention earlier and had got into 1.7. |
|
SGTM |
71da693 to
c063c8c
Compare
|
Refreshed the patch. This time using map[string]string instead of interface{}. One can still acess the fields using docker template as follows. docker inspect --format='{{.GraphDriver.Name}}' fedora |
|
This is how the additional exported information look like in docker-inspect. |
|
Having examples from overlayfs and other back ends might help to move this along? What do you think @jfrazelle @tianon @crosbymichael |
|
I looked into this for btrfs, but none of stats and usage is plumbed yet in
|
|
For vfs we might be done with simply exporting directory of container. For things like overlayfs, I think just exporting container directory might not be sufficient. Somebody will have to setup container mount point with proper lower and upper directories and that should happen in caller. So we might have to export this upper and lower dir information too. |
|
A map looks more appropriate, thanks for changing that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this lock here? The devices struct is not used after locking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can get rid of devives.Lock() as I am not making use of it.
|
Having some tests would be great! |
|
Ok, I will look into adding test. |
c063c8c to
ed08580
Compare
|
Pushed patch one more time. This time added 2 new tests and extended 1 existing one. Also got rid of devices.lock. my test have run against "vfs" locally. Not sure How to force running tests against "devicemapper" graphdriver. I tried "export DOCKER_GRAPHDRIVER=devicemapper; make test-integration-cli" and that fails very early. |
|
Added this to the 1.8 milestone; let's work on getting it into that release! (And the experimental builds?) |
|
@thaJeztah Given that it can't make 1.7, I can live with 1.8. What's experimental builds? |
|
@rhvgoyal not sure if this applies to this PR, but starting with the 1.7 release, Docker will have three "release channels";
The experimental release includes new features that are being worked on and hidden behind an Features in experimental builds are not guaranteed to end up in an official release; this allows the team to "pull the plug" on them (hopefully not, of course), without the headaches of breaking production setups. |
ed08580 to
f6c3899
Compare
|
Refreshed patch one more time. This time added another field "DeviceName". This exports the name of the dm device docker will use for image/container. |
|
LGTM |
…ata related to graph driver Export image/container metadata stored in graph driver. Right now 3 fields DeviceId, DeviceSize and DeviceName are being exported from devicemapper. Other graph drivers can export fields as they see fit. This data can be used to mount the thin device outside of docker and tools can look into image/container and do some kind of inspection. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
f6c3899 to
407a626
Compare
|
Refreshed the patch on top of latest code. |
|
LGTM |
docker-inspect: Extend docker inspect to export image metadata related to graph driver
|
WooHoo |
Fixes issue #13197
Export image metadata stored in graph driver. Right now two fields "Device ID"
and "Device Size" are being exported from devicemapper. Other graph drivers can
export fields as they seem fit.
This data can be used to mount the thin device outside of docker and tools
can look into image and do some kind of inspection.
Signed-off-by: Vivek Goyal vgoyal@redhat.com