aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/commands.go2
-rw-r--r--cmd/podman/container.go1
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/shared/intermediate_varlink.go14
-rw-r--r--cmd/podman/start.go104
5 files changed, 18 insertions, 104 deletions
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 0e5deb627..1a2da86cf 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -22,7 +22,6 @@ func getMainCommands() []*cobra.Command {
_refreshCommand,
_restartCommand,
_searchCommand,
- _startCommand,
_statsCommand,
_topCommand,
_unpauseCommand,
@@ -57,7 +56,6 @@ func getContainerSubCommands() []*cobra.Command {
_restartCommand,
_restoreCommand,
_runlabelCommand,
- _startCommand,
_statsCommand,
_stopCommand,
_topCommand,
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index 39c4f0c5d..1477d158f 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -61,6 +61,7 @@ var (
_logsCommand,
_runCommand,
_rmCommand,
+ _startCommand,
_waitCommand,
}
)
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index e8c3e14ea..2748df5f5 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -59,6 +59,7 @@ var mainCommands = []*cobra.Command{
_versionCommand,
_waitCommand,
imageCommand.Command,
+ _startCommand,
systemCommand.Command,
}
diff --git a/cmd/podman/shared/intermediate_varlink.go b/cmd/podman/shared/intermediate_varlink.go
index 95a0d6287..d62a65955 100644
--- a/cmd/podman/shared/intermediate_varlink.go
+++ b/cmd/podman/shared/intermediate_varlink.go
@@ -4,8 +4,10 @@ package shared
import (
"fmt"
+
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
)
@@ -318,6 +320,12 @@ func VarlinkCreateToGeneric(opts iopodman.Create) GenericCLIResults {
// We do not get a default network over varlink. Unlike the other default values for some cli
// elements, it seems it gets set to the default anyway.
+ var memSwapDefault int64 = -1
+ netModeDefault := "bridge"
+ if rootless.IsRootless() {
+ netModeDefault = "slirp4netns"
+ }
+
m := make(map[string]GenericCLIResult)
m["add-host"] = stringSliceFromVarlink(opts.AddHost, "add-host", nil)
m["annotation"] = stringSliceFromVarlink(opts.Annotation, "annotation", nil)
@@ -374,10 +382,10 @@ func VarlinkCreateToGeneric(opts iopodman.Create) GenericCLIResults {
m["memory"] = stringFromVarlink(opts.Memory, "memory", nil)
m["memory-reservation"] = stringFromVarlink(opts.MemoryReservation, "memory-reservation", nil)
m["memory-swap"] = stringFromVarlink(opts.MemorySwap, "memory-swap", nil)
- m["memory-swappiness"] = int64FromVarlink(opts.MemorySwappiness, "memory-swappiness", nil)
+ m["memory-swappiness"] = int64FromVarlink(opts.MemorySwappiness, "memory-swappiness", &memSwapDefault)
m["name"] = stringFromVarlink(opts.Name, "name", nil)
- m["net"] = stringFromVarlink(opts.Net, "net", nil)
- m["network"] = stringFromVarlink(opts.Network, "network", nil)
+ m["net"] = stringFromVarlink(opts.Net, "net", &netModeDefault)
+ m["network"] = stringFromVarlink(opts.Network, "network", &netModeDefault)
m["no-hosts"] = boolFromVarlink(opts.NoHosts, "no-hosts", false)
m["oom-kill-disable"] = boolFromVarlink(opts.OomKillDisable, "oon-kill-disable", false)
m["oom-score-adj"] = intFromVarlink(opts.OomScoreAdj, "oom-score-adj", nil)
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index ec05ce90e..9f93061f9 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -1,16 +1,11 @@
package main
import (
- "fmt"
- "os"
-
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
- opentracing "github.com/opentracing/opentracing-go"
+ "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -48,7 +43,7 @@ func init() {
}
func startCmd(c *cliconfig.StartValues) error {
- if c.Bool("trace") {
+ if !remoteclient && c.Bool("trace") {
span, _ := opentracing.StartSpanFromContext(Ctx, "startCmd")
defer span.Finish()
}
@@ -70,100 +65,11 @@ func startCmd(c *cliconfig.StartValues) error {
return errors.Wrapf(libpod.ErrInvalidArg, "you cannot use sig-proxy without --attach")
}
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- if c.Latest {
- lastCtr, err := runtime.GetLatestContainer()
- if err != nil {
- return errors.Wrapf(err, "unable to get latest container")
- }
- args = append(args, lastCtr.ID())
- }
-
- ctx := getContext()
-
- var lastError error
- for _, container := range args {
- ctr, err := runtime.LookupContainer(container)
- if err != nil {
- if lastError != nil {
- fmt.Fprintln(os.Stderr, lastError)
- }
- lastError = errors.Wrapf(err, "unable to find container %s", container)
- continue
- }
-
- ctrState, err := ctr.State()
- if err != nil {
- return errors.Wrapf(err, "unable to get container state")
- }
-
- ctrRunning := ctrState == libpod.ContainerStateRunning
-
- if attach {
- inputStream := os.Stdin
- if !c.Interactive {
- inputStream = nil
- }
-
- // attach to the container and also start it not already running
- // If the container is in a pod, also set to recursively start dependencies
- err = adapter.StartAttachCtr(ctx, ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, sigProxy, !ctrRunning, ctr.PodID() != "")
- if errors.Cause(err) == libpod.ErrDetach {
- // User manually detached
- // Exit cleanly immediately
- exitCode = 0
- return nil
- }
-
- if ctrRunning {
- return err
- }
-
- if err != nil {
- return errors.Wrapf(err, "unable to start container %s", ctr.ID())
- }
-
- if ecode, err := ctr.Wait(); err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
- // The container may have been removed
- // Go looking for an exit file
- rtc, err := runtime.GetConfig()
- if err != nil {
- return err
- }
- ctrExitCode, err := adapter.ReadExitFile(rtc.TmpDir, ctr.ID())
- if err != nil {
- logrus.Errorf("Cannot get exit code: %v", err)
- exitCode = 127
- } else {
- exitCode = ctrExitCode
- }
- }
- } else {
- exitCode = int(ecode)
- }
-
- return nil
- }
- if ctrRunning {
- fmt.Println(ctr.ID())
- continue
- }
- // Handle non-attach start
- // 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)
- }
- lastError = errors.Wrapf(err, "unable to start container %q", container)
- continue
- }
- fmt.Println(container)
- }
-
- return lastError
+ exitCode, err = runtime.Start(getContext(), c, sigProxy)
+ return err
}