diff options
Diffstat (limited to 'cmd')
32 files changed, 107 insertions, 58 deletions
diff --git a/cmd/podman/attach.go b/cmd/podman/attach.go index ed175bdf4..b70ff649c 100644 --- a/cmd/podman/attach.go +++ b/cmd/podman/attach.go @@ -22,7 +22,9 @@ var ( attachCommand.GlobalFlags = MainGlobalOpts return attachCmd(&attachCommand) }, - Example: "", + Example: `podman attach ctrID + podman attach 1234 + podman attach --no-stdin foobar`, } ) @@ -74,7 +76,8 @@ func attachCmd(c *cliconfig.AttachValues) error { inputStream = nil } - if err := startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, c.SigProxy, false); err != nil && errors.Cause(err) != libpod.ErrDetach { + // If the container is in a pod, also set to recursively start dependencies + if err := startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, c.SigProxy, false, ctr.PodID() != ""); err != nil && errors.Cause(err) != libpod.ErrDetach { return errors.Wrapf(err, "error attaching to container %s", ctr.ID()) } diff --git a/cmd/podman/build.go b/cmd/podman/build.go index 30a734377..bb252f171 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -40,7 +40,9 @@ var ( buildCommand.NameSpaceResults = &namespaceValues return buildCmd(&buildCommand) }, - Example: "CONTEXT-DIRECTORY | URL", + Example: `podman build . + podman build --cert-dir ~/auth --creds=username:password -t imageName -f Dockerfile.simple . + podman build --layers --force-rm --tag imageName .`, } ) diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go index aa4034ccd..3484e8957 100644 --- a/cmd/podman/checkpoint.go +++ b/cmd/podman/checkpoint.go @@ -29,7 +29,9 @@ var ( checkpointCommand.GlobalFlags = MainGlobalOpts return checkpointCmd(&checkpointCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman checkpoint --keep ctrID + podman checkpoint --all + podman checkpoint --leave-running --latest`, } ) diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 7bfb070c7..e7efe7502 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -399,9 +399,6 @@ func parseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l tty := c.Bool("tty") - if c.Bool("detach") && c.Bool("rm") { - return nil, errors.Errorf("--rm and --detach cannot be specified together") - } if c.Flag("cpu-period").Changed && c.Flag("cpus").Changed { return nil, errors.Errorf("--cpu-period and --cpus cannot be set together") } diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go index 7d4cc1b58..e2d258ad4 100644 --- a/cmd/podman/diff.go +++ b/cmd/podman/diff.go @@ -46,7 +46,9 @@ var ( diffCommand.GlobalFlags = MainGlobalOpts return diffCmd(&diffCommand) }, - Example: "ID-NAME", + Example: `podman diff imageID + podman diff ctrID + podman diff --format json redis:alpine`, } ) diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go index 74808768e..9599be528 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -29,7 +29,9 @@ var ( execCommand.GlobalFlags = MainGlobalOpts return execCmd(&execCommand) }, - Example: "CONTAINER-NAME", + Example: `podman exec -it ctrID ls + podman exec -it -w /tmp myCtr pwd + podman exec --user root ctrID ls`, } ) diff --git a/cmd/podman/export.go b/cmd/podman/export.go index 2ce8186a1..a593a4753 100644 --- a/cmd/podman/export.go +++ b/cmd/podman/export.go @@ -25,7 +25,8 @@ var ( exportCommand.GlobalFlags = MainGlobalOpts return exportCmd(&exportCommand) }, - Example: "CONTAINER", + Example: `podman export ctrID > myCtr.tar + podman export --output="myCtr.tar" ctrID`, } ) diff --git a/cmd/podman/import.go b/cmd/podman/import.go index 32f79757b..053408ff3 100644 --- a/cmd/podman/import.go +++ b/cmd/podman/import.go @@ -25,7 +25,9 @@ var ( importCommand.GlobalFlags = MainGlobalOpts return importCmd(&importCommand) }, - Example: "TARBALL [REFERENCE]", + Example: `podman import http://example.com/ctr.tar url-image + cat ctr.tar | podman -q import --message "importing the ctr.tar tarball" - image-imported + cat ctr.tar | podman import -`, } ) diff --git a/cmd/podman/kill.go b/cmd/podman/kill.go index d922cf721..1be4fa959 100644 --- a/cmd/podman/kill.go +++ b/cmd/podman/kill.go @@ -28,7 +28,9 @@ var ( killCommand.GlobalFlags = MainGlobalOpts return killCmd(&killCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman kill mywebserver + podman kill 860a4b23 + podman kill --signal TERM ctrID`, } ) diff --git a/cmd/podman/login.go b/cmd/podman/login.go index 3eacab54a..b02a4b3f9 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -112,7 +112,7 @@ func loginCmd(c *cliconfig.LoginValues) error { } // If no username and no password is specified, try to use existing ones. - if c.Username == "" && password == "" { + if c.Username == "" && password == "" && userFromAuthFile != "" && passFromAuthFile != "" { fmt.Println("Authenticating with existing credentials...") if err := docker.CheckAuth(ctx, sc, userFromAuthFile, passFromAuthFile, server); err == nil { fmt.Println("Existing credentials are valid. Already logged in to", server) diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go index 5fecf814e..4108887f0 100644 --- a/cmd/podman/logout.go +++ b/cmd/podman/logout.go @@ -22,7 +22,9 @@ var ( logoutCommand.GlobalFlags = MainGlobalOpts return logoutCmd(&logoutCommand) }, - Example: "REGISTRY", + Example: `podman logout docker.io + podman logout --authfile authdir/myauths.json docker.io + podman logout --all`, } ) diff --git a/cmd/podman/pause.go b/cmd/podman/pause.go index a840cbe49..94bb0edfe 100644 --- a/cmd/podman/pause.go +++ b/cmd/podman/pause.go @@ -28,7 +28,9 @@ var ( pauseCommand.GlobalFlags = MainGlobalOpts return pauseCmd(&pauseCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman pause mywebserver + podman pause 860a4b23 + podman stop -a`, } ) diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go index 4ecd30cd4..9fc06dde9 100644 --- a/cmd/podman/play_kube.go +++ b/cmd/podman/play_kube.go @@ -37,7 +37,8 @@ var ( playKubeCommand.GlobalFlags = MainGlobalOpts return playKubeYAMLCmd(&playKubeCommand) }, - Example: "Kubernetes YAML file", + Example: `podman play kube demo.yml + podman play kube --cert-dir /mycertsdir --tls-verify=true --quiet myWebPod`, } ) @@ -154,7 +155,7 @@ func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error { // start the containers for _, ctr := range containers { - if err := ctr.Start(ctx); err != nil { + if err := ctr.Start(ctx, false); err != nil { // Making this a hard failure here to avoid a mess // the other containers are in created status return err diff --git a/cmd/podman/pod_start.go b/cmd/podman/pod_start.go index 829fe2107..d093c51cf 100644 --- a/cmd/podman/pod_start.go +++ b/cmd/podman/pod_start.go @@ -26,7 +26,9 @@ var ( podStartCommand.GlobalFlags = MainGlobalOpts return podStartCmd(&podStartCommand) }, - Example: "POD-NAME [POD-NAME ...]", + Example: `podman pod start podID + podman pod start --latest + podman pod start --all`, } ) diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go index 7afab6be9..b1779532f 100644 --- a/cmd/podman/pod_stats.go +++ b/cmd/podman/pod_stats.go @@ -32,7 +32,9 @@ var ( podStatsCommand.GlobalFlags = MainGlobalOpts return podStatsCmd(&podStatsCommand) }, - Example: "[POD_NAME_OR_ID]", + Example: `podman stats -a --no-stream + podman stats --no-reset ctrID + podman stats --no-stream --format "table {{.ID}} {{.Name}} {{.MemUsage}}" ctrID`, } ) diff --git a/cmd/podman/pod_stop.go b/cmd/podman/pod_stop.go index 80082045d..a9237347e 100644 --- a/cmd/podman/pod_stop.go +++ b/cmd/podman/pod_stop.go @@ -27,7 +27,9 @@ var ( podStopCommand.GlobalFlags = MainGlobalOpts return podStopCmd(&podStopCommand) }, - Example: "POD-NAME [POD-NAME ...]", + Example: `podman pod stop mywebserverpod + podman pod stop --latest + podman pod stop --timeout 0 490eb 3557fb`, } ) diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go index 411c782bd..790118496 100644 --- a/cmd/podman/pod_top.go +++ b/cmd/podman/pod_top.go @@ -33,7 +33,9 @@ the latest pod. podTopCommand.GlobalFlags = MainGlobalOpts return podTopCmd(&podTopCommand) }, - Example: "POD-NAME [format descriptors]", + Example: `podman top ctrID + podman top --latest + podman top --latest pid seccomp args %C`, } ) diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 949f78a34..482e423b7 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -166,7 +166,9 @@ var ( psCommand.GlobalFlags = MainGlobalOpts return psCmd(&psCommand) }, - Example: "", + Example: `podman ps -a + podman ps -a --format "{{.ID}} {{.Image}} {{.Labels}} {{.Mounts}}" + podman ps --size --sort names`, } ) diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go index 6e060d6f5..859228cbd 100644 --- a/cmd/podman/pull.go +++ b/cmd/podman/pull.go @@ -36,7 +36,9 @@ specified, the image with the 'latest' tag (if it exists) is pulled pullCommand.GlobalFlags = MainGlobalOpts return pullCmd(&pullCommand) }, - Example: "", + Example: `podman pull imageName + podman pull --cert-dir image/certs --authfile temp-auths/myauths.json docker://docker.io/myrepo/finaltest + podman pull fedora:latest`, } ) diff --git a/cmd/podman/push.go b/cmd/podman/push.go index bbe8a4027..881d8cebc 100644 --- a/cmd/podman/push.go +++ b/cmd/podman/push.go @@ -34,7 +34,9 @@ var ( pushCommand.GlobalFlags = MainGlobalOpts return pushCmd(&pushCommand) }, - Example: "IMAGE DESTINATION", + Example: `podman push imageID docker://registry.example.com/repository:tag + podman push imageID oci-archive:/path/to/layout:image:tag + podman push --authfile temp-auths/myauths.json alpine docker://docker.io/myrepo/alpine`, } ) diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index d170e5357..2e5fe1dc0 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -28,7 +28,9 @@ Running containers will not be removed without the -f option. rmCommand.GlobalFlags = MainGlobalOpts return rmCmd(&rmCommand) }, - Example: "", + Example: `podman rm imageID + podman rm mywebserver myflaskserver 860a4b23 + podman rm --force --all`, } ) diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index c5bd1e190..fb27772f5 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -23,7 +23,9 @@ var ( rmiCommand.GlobalFlags = MainGlobalOpts return rmiCmd(&rmiCommand) }, - Example: "IMAGE-NAME-OR-ID [...]", + Example: `podman rmi imageID + podman rmi --force alpine + podman rmi c4dfb1609ee2 93fd78260bd1 c0ed59d05ff7`, } ) diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 64f8b6856..ff4c3b418 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -30,7 +30,9 @@ var ( runCommand.GlobalFlags = MainGlobalOpts return runCmd(&runCommand) }, - Example: "IMAGE [COMMAND [ARG...]]", + Example: `podman run imageID ls -alF /etc + podman run --net=host imageID dnf -y install java + podman run --volume /var/hostdir:/var/ctrdir -i -t fedora /bin/bash`, } ) @@ -72,7 +74,8 @@ func runCmd(c *cliconfig.RunValues) error { ctx := getContext() // Handle detached start if createConfig.Detach { - if err := ctr.Start(ctx); err != nil { + // if the container was created as part of a pod, also start its dependencies, if any. + if err := ctr.Start(ctx, c.IsSet("pod")); err != nil { // This means the command did not exist exitCode = 127 if strings.Index(err.Error(), "permission denied") > -1 { @@ -117,7 +120,8 @@ func runCmd(c *cliconfig.RunValues) error { } } } - if err := startAttachCtr(ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.Bool("sig-proxy"), true); err != nil { + // if the container was created as part of a pod, also start its dependencies, if any. + if err := startAttachCtr(ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.Bool("sig-proxy"), true, c.IsSet("pod")); err != nil { // We've manually detached from the container // Do not perform cleanup, or wait for container exit code // Just exit immediately @@ -125,7 +129,6 @@ func runCmd(c *cliconfig.RunValues) error { exitCode = 0 return nil } - // This means the command did not exist exitCode = 127 if strings.Index(err.Error(), "permission denied") > -1 { diff --git a/cmd/podman/sign.go b/cmd/podman/sign.go index ac0d985f5..6e8f9ee95 100644 --- a/cmd/podman/sign.go +++ b/cmd/podman/sign.go @@ -32,7 +32,8 @@ var ( signCommand.GlobalFlags = MainGlobalOpts return signCmd(&signCommand) }, - Example: "IMAGE-NAME [IMAGE-NAME ...]", + Example: `podman sign --sign-by mykey imageID + podman sign --sign-by mykey --directory ./mykeydir imageID`, } ) diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 3a606d662..f3639cb23 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -1,14 +1,12 @@ package main import ( - "encoding/json" "fmt" "os" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/libpod" - cc "github.com/containers/libpod/pkg/spec" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -30,7 +28,9 @@ var ( startCommand.GlobalFlags = MainGlobalOpts return startCmd(&startCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman start --latest + podman start 860a4b231279 5421ab43b45 + podman start --interactive --attach imageID`, } ) @@ -107,7 +107,8 @@ func startCmd(c *cliconfig.StartValues) error { } // attach to the container and also start it not already running - err = startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, sigProxy, !ctrRunning) + // If the container is in a pod, also set to recursively start dependencies + err = startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, sigProxy, !ctrRunning, ctr.PodID() != "") if errors.Cause(err) == libpod.ErrDetach { // User manually detached // Exit cleanly immediately @@ -124,31 +125,30 @@ func startCmd(c *cliconfig.StartValues) error { } if ecode, err := ctr.Wait(); err != nil { - logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err) + if errors.Cause(err) == libpod.ErrNoSuchCtr { + // The container may have been removed + // Go looking for an exit file + ctrExitCode, err := readExitFile(runtime.GetConfig().TmpDir, ctr.ID()) + if err != nil { + logrus.Errorf("Cannot get exit code: %v", err) + exitCode = 127 + } else { + exitCode = ctrExitCode + } + } } else { exitCode = int(ecode) } - return ctr.Cleanup(ctx) + return nil } if ctrRunning { fmt.Println(ctr.ID()) continue } // Handle non-attach start - if err := ctr.Start(ctx); err != nil { - var createArtifact cc.CreateConfig - artifact, artifactErr := ctr.GetArtifact("create-config") - if artifactErr == nil { - if jsonErr := json.Unmarshal(artifact, &createArtifact); jsonErr != nil { - logrus.Errorf("unable to detect if container %s should be deleted", ctr.ID()) - } - if createArtifact.Rm { - if rmErr := runtime.RemoveContainer(ctx, ctr, true, false); rmErr != nil { - logrus.Errorf("unable to remove container %s after it failed to start", ctr.ID()) - } - } - } + // If the container is in a pod, also set to recursively start dependencies + if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) } diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index 134d8a069..15c3984f4 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -31,7 +31,9 @@ var ( stopCommand.GlobalFlags = MainGlobalOpts return stopCmd(&stopCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman stop ctrID + podman stop --latest + podman stop --timeout 2 mywebserver 6e534f14da9d`, } ) diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go index f3d1cadce..0a4783d0a 100644 --- a/cmd/podman/trust_set_show.go +++ b/cmd/podman/trust_set_show.go @@ -26,7 +26,7 @@ var ( Use: "set", Short: "Set default trust policy or a new trust policy for a registry", Long: setTrustDescription, - Example: "default | REGISTRY[/REPOSITORY]", + Example: "", RunE: func(cmd *cobra.Command, args []string) error { setTrustCommand.InputArgs = args setTrustCommand.GlobalFlags = MainGlobalOpts diff --git a/cmd/podman/umount.go b/cmd/podman/umount.go index 20ea410c2..afa0e86db 100644 --- a/cmd/podman/umount.go +++ b/cmd/podman/umount.go @@ -31,7 +31,9 @@ An unmount can be forced with the --force flag. umountCommand.GlobalFlags = MainGlobalOpts return umountCmd(&umountCommand) }, - Example: "CONTAINER-NAME-OR-ID", + Example: `podman umount ctrID + podman umount ctrID1 ctrID2 ctrID3 + podman umount --all`, } ) diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go index c8f85cfd3..efd9a20a3 100644 --- a/cmd/podman/unpause.go +++ b/cmd/podman/unpause.go @@ -29,7 +29,8 @@ var ( unpauseCommand.GlobalFlags = MainGlobalOpts return unpauseCmd(&unpauseCommand) }, - Example: "CONTAINER-NAME [CONTAINER-NAME ...]", + Example: `podman unpause ctrID + podman unpause --all`, } ) diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index 744d010d5..c76e7f2a4 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -20,7 +20,7 @@ type RawTtyFormatter struct { } // Start (if required) and attach to a container -func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool) error { +func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool, recursive bool) error { ctx := context.Background() resize := make(chan remotecommand.TerminalSize) @@ -76,7 +76,7 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac return ctr.Attach(streams, detachKeys, resize) } - attachChan, err := ctr.StartAndAttach(getContext(), streams, detachKeys, resize) + attachChan, err := ctr.StartAndAttach(getContext(), streams, detachKeys, resize, recursive) if err != nil { return err } diff --git a/cmd/podman/volume_create.go b/cmd/podman/volume_create.go index fe5d69e0b..6c8a78922 100644 --- a/cmd/podman/volume_create.go +++ b/cmd/podman/volume_create.go @@ -26,7 +26,9 @@ be created at.` volumeCreateCommand.GlobalFlags = MainGlobalOpts return volumeCreateCmd(&volumeCreateCommand) }, - Example: "[VOLUME-NAME]", + Example: `podman volume create myvol + podman volume create + podman volume create --label foo=bar myvol`, } ) diff --git a/cmd/podman/volume_inspect.go b/cmd/podman/volume_inspect.go index 928ef37d0..3b4ba51d5 100644 --- a/cmd/podman/volume_inspect.go +++ b/cmd/podman/volume_inspect.go @@ -24,7 +24,9 @@ from JSON to a Go template. volumeInspectCommand.GlobalFlags = MainGlobalOpts return volumeInspectCmd(&volumeInspectCommand) }, - Example: "[VOLUME-NAME ...]", + Example: `podman volume inspect myvol + podman volume inspect --all + podman volume inspect --format "{{.Driver}} {{.Scope}}" myvol`, } ) |