diff options
-rw-r--r-- | cmd/podman/container.go | 19 | ||||
-rw-r--r-- | cmd/podman/image.go | 18 | ||||
-rw-r--r-- | cmd/podman/inspect.go | 38 | ||||
-rw-r--r-- | cmd/podman/main.go | 2 | ||||
-rw-r--r-- | cmd/podman/run.go | 4 | ||||
-rw-r--r-- | docs/podman-build.1.md | 14 | ||||
-rw-r--r-- | docs/podman-inspect.1.md | 11 | ||||
-rw-r--r-- | libpod/networking_linux.go | 4 | ||||
-rw-r--r-- | test/e2e/commit_test.go | 2 |
9 files changed, 86 insertions, 26 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/cmd/podman/run.go b/cmd/podman/run.go index 130c5a32c..a92d5d3db 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -166,6 +166,10 @@ func runCmd(c *cliconfig.RunValues) error { exitCode = int(ecode) } + if c.IsSet("rm") { + runtime.RemoveContainer(ctx, ctr, false, true) + } + return nil } diff --git a/docs/podman-build.1.md b/docs/podman-build.1.md index fdae48b93..3d51a5319 100644 --- a/docs/podman-build.1.md +++ b/docs/podman-build.1.md @@ -209,7 +209,7 @@ Write the image ID to the file. Sets the configuration for IPC namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate that a new IPC namespace should be created, or it can be "host" to indicate -that the IPC namespace in which `buildah` itself is being run should be reused, +that the IPC namespace in which `podman` itself is being run should be reused, or it can be the path to an IPC namespace which is already in use by another process. @@ -269,7 +269,7 @@ unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap. Sets the configuration for network namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate that a new network namespace should be created, or it can be "host" to indicate -that the network namespace in which `buildah` itself is being run should be +that the network namespace in which `podman` itself is being run should be reused, or it can be the path to a network namespace which is already in use by another process. @@ -282,7 +282,7 @@ Do not use existing cached images for the container build. Build from the start Sets the configuration for PID namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate that a new PID namespace should be created, or it can be "host" to indicate -that the PID namespace in which `buildah` itself is being run should be reused, +that the PID namespace in which `podman` itself is being run should be reused, or it can be the path to a PID namespace which is already in use by another process. @@ -398,7 +398,7 @@ include: Sets the configuration for user namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate that a new user namespace should be created, it can be "host" to indicate that -the user namespace in which `buildah` itself is being run should be reused, or +the user namespace in which `podman` itself is being run should be reused, or it can be the path to an user namespace which is already in use by another process. @@ -452,7 +452,7 @@ in the `/etc/subuid` file which correspond to the specified user. Commands run when handling `RUN` instructions will default to being run in their own user namespaces, configured using the UID and GID maps. If --userns-gid-map-group is specified, but --userns-uid-map-user is not -specified, `buildah` will assume that the specified group name is also a +specified, `podman` will assume that the specified group name is also a suitable user name to use as the default setting for this option. **--userns-gid-map-group** *group* @@ -463,7 +463,7 @@ in the `/etc/subgid` file which correspond to the specified group. Commands run when handling `RUN` instructions will default to being run in their own user namespaces, configured using the UID and GID maps. If --userns-uid-map-user is specified, but --userns-gid-map-group is not -specified, `buildah` will assume that the specified user name is also a +specified, `podman` will assume that the specified user name is also a suitable group name to use as the default setting for this option. **--uts** *how* @@ -471,7 +471,7 @@ suitable group name to use as the default setting for this option. Sets the configuration for UTS namespaces when the handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate that a new UTS namespace should be created, or it can be "host" to indicate -that the UTS namespace in which `buildah` itself is being run should be reused, +that the UTS namespace in which `podman` itself is being run should be reused, or it can be the path to a UTS namespace which is already in use by another process. 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/libpod/networking_linux.go b/libpod/networking_linux.go index 80d7d8213..b7f1c2f1b 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -162,9 +162,9 @@ func (r *Runtime) setupRootlessNetNS(ctr *Container) (err error) { var cmd *exec.Cmd if havePortMapping { // if we need ports to be mapped from the host, create a API socket to use for communicating with slirp4netns. - cmd = exec.Command(path, "-c", "-e", "3", "-r", "4", "--api-socket", apiSocket, fmt.Sprintf("%d", ctr.state.PID), "tap0") + cmd = exec.Command(path, "--mtu", "65520", "-c", "-e", "3", "-r", "4", "--api-socket", apiSocket, fmt.Sprintf("%d", ctr.state.PID), "tap0") } else { - cmd = exec.Command(path, "-c", "-e", "3", "-r", "4", fmt.Sprintf("%d", ctr.state.PID), "tap0") + cmd = exec.Command(path, "--mtu", "65520", "-c", "-e", "3", "-r", "4", fmt.Sprintf("%d", ctr.state.PID), "tap0") } cmd.SysProcAttr = &syscall.SysProcAttr{ 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()) |