Flag Addition: --type flag added for docker inspect command

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
This commit is contained in:
Shishir Mahajan 2015-06-26 10:47:31 -04:00 committed by Tibor Vass
parent 7cd538db6f
commit 24e7d40f42
3 changed files with 31 additions and 7 deletions

View File

@ -527,11 +527,16 @@ _docker_inspect() {
--format|-f) --format|-f)
return return
;; ;;
--type)
COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
return
;;
esac esac
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--format -f --type --help" -- "$cur" ) )
;; ;;
*) *)
__docker_containers_and_images __docker_containers_and_images

View File

@ -17,6 +17,9 @@ weight=1
-f, --format="" Format the output using the given go template -f, --format="" Format the output using the given go template
--type=container|image Return JSON for specified type, permissible
values are "image" or "container"
By default, this will render all results in a JSON array. If a format is By default, this will render all results in a JSON array. If a format is
specified, the given template will be executed for each result. specified, the given template will be executed for each result.

View File

@ -8,6 +8,7 @@ docker-inspect - Return low-level information on a container or image
**docker inspect** **docker inspect**
[**--help**] [**--help**]
[**-f**|**--format**[=*FORMAT*]] [**-f**|**--format**[=*FORMAT*]]
[**--type**=*container*|*image*]
CONTAINER|IMAGE [CONTAINER|IMAGE...] CONTAINER|IMAGE [CONTAINER|IMAGE...]
# DESCRIPTION # DESCRIPTION
@ -24,14 +25,29 @@ each result.
**-f**, **--format**="" **-f**, **--format**=""
Format the output using the given go template. Format the output using the given go template.
**--type**=*container*|*image*
Return JSON for specified type, permissible values are "image" or "container"
# EXAMPLES # EXAMPLES
Getting information on an image where image name conflict with the container name,
e,g both image and container are named rhel7.
$ docker inspect --type=image rhel7
[
{
"Id": "fe01a428b9d9de35d29531e9994157978e8c48fa693e1bf1d221dffbbb67b170",
"Parent": "10acc31def5d6f249b548e01e8ffbaccfd61af0240c17315a7ad393d022c5ca2",
....
}
]
## Getting information on a container ## Getting information on a container
To get information on a container use its ID or instance name: To get information on a container use its ID or instance name:
$ docker inspect d2cc496561d6 $ docker inspect d2cc496561d6
[{ [{
"Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47", "Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
"Created": "2015-06-08T16:18:02.505155285Z", "Created": "2015-06-08T16:18:02.505155285Z",
"Path": "bash", "Path": "bash",
@ -161,8 +177,8 @@ To get information on a container use its ID or instance name:
"CpuShares": 0, "CpuShares": 0,
"Cpuset": "" "Cpuset": ""
} }
} }
] ]
## Getting the IP address of a container instance ## Getting the IP address of a container instance
To get the IP address of a container use: To get the IP address of a container use:
@ -188,7 +204,7 @@ Use an image's ID or name (e.g., repository/name[:tag]) to get information
on it. on it.
$ docker inspect ded7cd95e059 $ docker inspect ded7cd95e059
[{ [{
"Id": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4", "Id": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
"Parent": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731", "Parent": "48ecf305d2cf7046c1f5f8fcbcd4994403173441d4a7f125b1bb0ceead9de731",
"Comment": "", "Comment": "",
@ -258,8 +274,8 @@ on it.
"DeviceSize": "171798691840" "DeviceSize": "171798691840"
} }
} }
} }
] ]
# HISTORY # HISTORY
April 2014, originally compiled by William Henry (whenry at redhat dot com) April 2014, originally compiled by William Henry (whenry at redhat dot com)