summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/build.go10
-rw-r--r--cmd/podman/cliconfig/config.go17
-rw-r--r--cmd/podman/commands.go2
-rw-r--r--cmd/podman/container.go1
-rw-r--r--cmd/podman/exec.go32
-rw-r--r--cmd/podman/healthcheck_run.go3
-rw-r--r--cmd/podman/images.go1
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/varlink/io.podman.varlink20
9 files changed, 53 insertions, 34 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go
index 5ee35dea0..19337985d 100644
--- a/cmd/podman/build.go
+++ b/cmd/podman/build.go
@@ -308,16 +308,6 @@ func buildCmd(c *cliconfig.BuildValues) error {
return runtime.Build(getContext(), c, options, dockerfiles)
}
-// Tail returns a string slice after the first element unless there are
-// not enough elements, then it returns an empty slice. This is to replace
-// the urfavecli Tail method for args
-func Tail(a []string) []string {
- if len(a) >= 2 {
- return a[1:]
- }
- return []string{}
-}
-
// useLayers returns false if BUILDAH_LAYERS is set to "0" or "false"
// otherwise it returns true
func useLayers() string {
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index be380cda0..025f40cf6 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -119,14 +119,15 @@ type DiffValues struct {
type ExecValues struct {
PodmanCommand
- Env []string
- Privileged bool
- Interfactive bool
- Tty bool
- User string
- Latest bool
- Workdir string
- PreserveFDs int
+ DetachKeys string
+ Env []string
+ Privileged bool
+ Interactive bool
+ Tty bool
+ User string
+ Latest bool
+ Workdir string
+ PreserveFDs int
}
type ImageExistsValues struct {
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 9229191ff..27f3fc214 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -11,7 +11,6 @@ const remoteclient = false
// Commands that the local client implements
func getMainCommands() []*cobra.Command {
rootCommands := []*cobra.Command{
- _execCommand,
_playCommand,
_loginCommand,
_logoutCommand,
@@ -41,7 +40,6 @@ func getContainerSubCommands() []*cobra.Command {
return []*cobra.Command{
_cleanupCommand,
- _execCommand,
_mountCommand,
_refreshCommand,
_runlabelCommand,
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index cb54317c0..557f5fafa 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -57,6 +57,7 @@ var (
_contInspectSubCommand,
_cpCommand,
_diffCommand,
+ _execCommand,
_exportCommand,
_createCommand,
_initCommand,
diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go
index 799ed9f38..2e9b9e47e 100644
--- a/cmd/podman/exec.go
+++ b/cmd/podman/exec.go
@@ -35,8 +35,9 @@ func init() {
execCommand.SetUsageTemplate(UsageTemplate())
flags := execCommand.Flags()
flags.SetInterspersed(false)
+ flags.StringVar(&execCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables")
- flags.BoolVarP(&execCommand.Interfactive, "interactive", "i", false, "Not supported. All exec commands are interactive by default")
+ flags.BoolVarP(&execCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVarP(&execCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&execCommand.Privileged, "privileged", false, "Give the process extended Linux capabilities inside the container. The default is false")
flags.BoolVarP(&execCommand.Tty, "tty", "t", false, "Allocate a pseudo-TTY. The default is false")
@@ -45,30 +46,35 @@ func init() {
flags.IntVar(&execCommand.PreserveFDs, "preserve-fds", 0, "Pass N additional file descriptors to the container")
flags.StringVarP(&execCommand.Workdir, "workdir", "w", "", "Working directory inside the container")
markFlagHiddenForRemoteClient("latest", flags)
+ markFlagHiddenForRemoteClient("preserve-fds", flags)
}
func execCmd(c *cliconfig.ExecValues) error {
- args := c.InputArgs
- argStart := 1
- if len(args) < 1 && !c.Latest {
- return errors.Errorf("you must provide one container name or id")
- }
- if len(args) < 2 && !c.Latest {
- return errors.Errorf("you must provide a command to exec")
- }
+ argLen := len(c.InputArgs)
if c.Latest {
- argStart = 0
+ if argLen < 1 {
+ return errors.Errorf("you must provide a command to exec")
+ }
+ } else {
+ if argLen < 1 {
+ return errors.Errorf("you must provide one container name or id")
+ }
+ if argLen < 2 {
+ return errors.Errorf("you must provide a command to exec")
+ }
}
- cmd := args[argStart:]
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.DeferredShutdown(false)
- err = runtime.Exec(c, cmd)
- if errors.Cause(err) == define.ErrCtrStateInvalid {
+ exitCode, err = runtime.ExecContainer(getContext(), c)
+ if errors.Cause(err) == define.ErrOCIRuntimePermissionDenied {
exitCode = 126
}
+ if errors.Cause(err) == define.ErrOCIRuntimeNotFound {
+ exitCode = 127
+ }
return err
}
diff --git a/cmd/podman/healthcheck_run.go b/cmd/podman/healthcheck_run.go
index 66ca4580a..3a2a8f333 100644
--- a/cmd/podman/healthcheck_run.go
+++ b/cmd/podman/healthcheck_run.go
@@ -44,6 +44,9 @@ func healthCheckCmd(c *cliconfig.HealthCheckValues) error {
}
defer runtime.DeferredShutdown(false)
status, err := runtime.HealthCheck(c)
+ if err == nil && status == "unhealthy" {
+ exitCode = 1
+ }
fmt.Println(status)
return err
}
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 3b32ee3dd..fe7c89b5c 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -51,7 +51,6 @@ type imagesOptions struct {
outputformat string
sort string
all bool
- useReadOnly bool
}
// Type declaration and functions for sorting the images output
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index a8478bda6..72d1754ac 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -35,6 +35,7 @@ var mainCommands = []*cobra.Command{
_diffCommand,
_createCommand,
_eventsCommand,
+ _execCommand,
_exportCommand,
_generateCommand,
_historyCommand,
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 72b15c328..cc66e7df0 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -500,6 +500,23 @@ type DiffInfo(
changeType: string
)
+type ExecOpts(
+ # container name or id
+ name: string,
+ # Create pseudo tty
+ tty: bool,
+ # privileged access in container
+ privileged: bool,
+ # command to execute in container
+ cmd: []string,
+ # user to use in container
+ user: ?string,
+ # workdir to run command in container
+ workdir: ?string,
+ # slice of keyword=value environment variables
+ env: ?[]string
+)
+
# GetVersion returns version and build information of the podman service
method GetVersion() -> (
version: string,
@@ -1100,6 +1117,9 @@ method ContainerRestore(name: string, keep: bool, tcpEstablished: bool) -> (id:
# ContainerRunlabel runs executes a command as described by a given container image label.
method ContainerRunlabel(runlabel: Runlabel) -> ()
+# ExecContainer executes a command in the given container.
+method ExecContainer(opts: ExecOpts) -> ()
+
# ListContainerMounts gathers all the mounted container mount points and returns them as an array
# of strings
# #### Example