summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/container.go19
-rw-r--r--cmd/podman/image.go18
-rw-r--r--cmd/podman/inspect.go38
-rw-r--r--cmd/podman/main.go2
-rw-r--r--docs/podman-inspect.1.md11
-rw-r--r--test/e2e/commit_test.go2
6 files changed, 73 insertions, 17 deletions
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index 8ad8d7a44..ce6ad8883 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -19,6 +19,20 @@ var (
},
}
+ contInspectSubCommand cliconfig.InspectValues
+ _contInspectSubCommand = &cobra.Command{
+ Use: strings.Replace(_inspectCommand.Use, "| IMAGE", "", 1),
+ Short: "Display the configuration of a container",
+ Long: `Displays the low-level information on a container identified by name or ID.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ contInspectSubCommand.InputArgs = args
+ contInspectSubCommand.GlobalFlags = MainGlobalOpts
+ return inspectCmd(&contInspectSubCommand)
+ },
+ Example: `podman container inspect myCtr
+ podman container inspect -l --format '{{.Id}} {{.Config.Labels}}'`,
+ }
+
listSubCommand cliconfig.PsValues
_listSubCommand = &cobra.Command{
Use: strings.Replace(_psCommand.Use, "ps", "list", 1),
@@ -37,12 +51,15 @@ var (
// Commands that are universally implemented.
containerCommands = []*cobra.Command{
_containerExistsCommand,
- _inspectCommand,
+ _contInspectSubCommand,
_listSubCommand,
}
)
func init() {
+ contInspectSubCommand.Command = _contInspectSubCommand
+ inspectInit(&contInspectSubCommand)
+
listSubCommand.Command = _listSubCommand
psInit(&listSubCommand)
diff --git a/cmd/podman/image.go b/cmd/podman/image.go
index 52bac6ecb..0e980d4d3 100644
--- a/cmd/podman/image.go
+++ b/cmd/podman/image.go
@@ -31,6 +31,19 @@ var (
Example: strings.Replace(_imagesCommand.Example, "podman images", "podman image list", -1),
}
+ inspectSubCommand cliconfig.InspectValues
+ _inspectSubCommand = &cobra.Command{
+ Use: strings.Replace(_inspectCommand.Use, "CONTAINER | ", "", 1),
+ Short: "Display the configuration of an image",
+ Long: `Displays the low-level information on an image identified by name or ID.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ inspectSubCommand.InputArgs = args
+ inspectSubCommand.GlobalFlags = MainGlobalOpts
+ return inspectCmd(&inspectSubCommand)
+ },
+ Example: `podman image inspect alpine`,
+ }
+
rmSubCommand cliconfig.RmiValues
_rmSubCommand = &cobra.Command{
Use: strings.Replace(_rmiCommand.Use, "rmi", "rm", 1),
@@ -52,7 +65,7 @@ var imageSubCommands = []*cobra.Command{
_imagesSubCommand,
_imageExistsCommand,
_importCommand,
- _inspectCommand,
+ _inspectSubCommand,
_loadCommand,
_pruneImagesCommand,
_pullCommand,
@@ -69,6 +82,9 @@ func init() {
imagesSubCommand.Command = _imagesSubCommand
imagesInit(&imagesSubCommand)
+ inspectSubCommand.Command = _inspectSubCommand
+ inspectInit(&inspectSubCommand)
+
imageCommand.SetUsageTemplate(UsageTemplate())
imageCommand.AddCommand(imageSubCommands...)
imageCommand.AddCommand(getImageSubCommands()...)
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index e14f25c24..3d6fd07e0 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -27,7 +27,7 @@ var (
inspectDescription = `This displays the low-level information on containers and images identified by name or ID.
If given a name that matches both a container and an image, this command inspects the container. By default, this will render all results in a JSON array.`
- _inspectCommand = &cobra.Command{
+ _inspectCommand = cobra.Command{
Use: "inspect [flags] CONTAINER | IMAGE",
Short: "Display the configuration of a container or image",
Long: inspectDescription,
@@ -42,16 +42,34 @@ var (
}
)
+func inspectInit(command *cliconfig.InspectValues) {
+ command.SetHelpTemplate(HelpTemplate())
+ command.SetUsageTemplate(UsageTemplate())
+ flags := command.Flags()
+ flags.StringVarP(&command.Format, "format", "f", "", "Change the output format to a Go template")
+
+ // -t flag applicable only to 'podman inspect', not 'image/container inspect'
+ ambiguous := strings.Contains(command.Use, "|")
+ if ambiguous {
+ flags.StringVarP(&command.TypeObject, "type", "t", inspectAll, "Return JSON for specified type, (image or container)")
+ }
+
+ if strings.Contains(command.Use, "CONTAINER") {
+ containers_only := " (containers only)"
+ if !ambiguous {
+ containers_only = ""
+ command.TypeObject = inspectTypeContainer
+ }
+ flags.BoolVarP(&command.Latest, "latest", "l", false, "Act on the latest container podman is aware of"+containers_only)
+ flags.BoolVarP(&command.Size, "size", "s", false, "Display total file size"+containers_only)
+ markFlagHiddenForRemoteClient("latest", flags)
+ } else {
+ command.TypeObject = inspectTypeImage
+ }
+}
func init() {
- inspectCommand.Command = _inspectCommand
- inspectCommand.SetHelpTemplate(HelpTemplate())
- inspectCommand.SetUsageTemplate(UsageTemplate())
- flags := inspectCommand.Flags()
- flags.StringVarP(&inspectCommand.TypeObject, "type", "t", inspectAll, "Return JSON for specified type, (e.g image, container or task)")
- flags.StringVarP(&inspectCommand.Format, "format", "f", "", "Change the output format to a Go template")
- flags.BoolVarP(&inspectCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of if the type is a container")
- flags.BoolVarP(&inspectCommand.Size, "size", "s", false, "Display total file size if the type is container")
- markFlagHiddenForRemoteClient("latest", flags)
+ inspectCommand.Command = &_inspectCommand
+ inspectInit(&inspectCommand)
}
func inspectCmd(c *cliconfig.InspectValues) error {
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 669860341..af6731d96 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -42,7 +42,7 @@ var mainCommands = []*cobra.Command{
&_imagesCommand,
_importCommand,
_infoCommand,
- _inspectCommand,
+ &_inspectCommand,
_killCommand,
_loadCommand,
podCommand.Command,
diff --git a/docs/podman-inspect.1.md b/docs/podman-inspect.1.md
index 5748f29f4..712891ad6 100644
--- a/docs/podman-inspect.1.md
+++ b/docs/podman-inspect.1.md
@@ -6,6 +6,10 @@ podman\-inspect - Display a container or image's configuration
## SYNOPSIS
**podman inspect** [*options*] *name* ...
+**podman image inspect** [*options*] *image*
+
+**podman container inspect** [*options*] *container*
+
## DESCRIPTION
This displays the low-level information on containers and images identified by name or ID. By default, this will render
all results in a JSON array. If the container and image have the same name, this will return container JSON for
@@ -16,6 +20,7 @@ unspecified type. If a format is specified, the given template will be executed
**--type, t="TYPE"**
Return JSON for the specified type. Type can be 'container', 'image' or 'all' (default: all)
+(Only meaningful when invoked as *podman inspect*)
**--format, -f="FORMAT"**
@@ -27,7 +32,7 @@ The keys of the returned JSON can be used as the values for the --format flag (s
Instead of providing the container name or ID, use the last created container. If you use methods other than Podman
to run containers such as CRI-O, the last started container could be from either of those methods.
-The latest option is not supported on the remote client.
+The latest option is not supported on the remote client or when invoked as *podman image inspect*.
**--size, -s**
@@ -94,12 +99,12 @@ overlay
```
```
-# podman inspect --format "size: {{.Size}}" alpine
+# podman image inspect --format "size: {{.Size}}" alpine
size: 4405240
```
```
-podman inspect --latest --format {{.EffectiveCaps}}
+podman container inspect --latest --format {{.EffectiveCaps}}
[CAP_CHOWN CAP_DAC_OVERRIDE CAP_FSETID CAP_FOWNER CAP_MKNOD CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SETFCAP CAP_SETPCAP CAP_NET_BIND_SERVICE CAP_SYS_CHROOT CAP_KILL CAP_AUDIT_WRITE]
```
diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go
index dff156441..bf9c88de5 100644
--- a/test/e2e/commit_test.go
+++ b/test/e2e/commit_test.go
@@ -58,7 +58,7 @@ var _ = Describe("Podman commit", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- check := podmanTest.Podman([]string{"container", "inspect", "foobar.com/test1-image:latest"})
+ check := podmanTest.Podman([]string{"image", "inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
data := check.InspectImageJSON()
Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue())