<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1194005000700189&amp;ev=PageView&amp;noscript=1">
VizuriBlogHero.jpg

From Vizuri's Experts

Be Specific When Inspecting Docker Objects

Here is an interesting tidbit having to do with docker inspect. The inspect function will return metadata associated with the object identifier that you include. That object identifier may be a container id, image id, name or other resource.

If you use a name as an argument instead of an image id or container id and you happen to have a container with the same name as an image, inspect might return the info for the one that you did not intend.

The way to be specific with your inspect request is to include the –type option which requires an argument of containerimage, volume or network.

The reason that you should include the type argument is demonstrated in the following example. 

The following will run a bash shell in an ubuntu container but will name it as python. 

docker run -it --name=python ubuntu bash

 

The following is how you might ask for an inspect on what you think is a python image.

docker inspect python

 

You might get back the metadata for the running container called python or you might get it for the image named python if there was one.

 

To be specific and indicate as to the resource the following refers to the image called python

docker inspect --type=image python 

 

This refers to the container called python.

docker inspect --type=container python

 

The importance of specificity is that it will alleviate the risk of getting back metadata of a different type than you expected which might impact an automation function such as a shell script. The side effects of getting back unexpected metadata might be that a script is unable to parse the response and cause an error.

 

Doug Toppin

Doug Toppin brought more than 30 years of experience in software systems design and development to his former role as a Vizuri developer. Interested in this post? Connect with our team of experts by