summaryrefslogtreecommitdiff
path: root/cmd/podman/create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-16 14:04:58 -0700
committerGitHub <noreply@github.com>2020-04-16 14:04:58 -0700
commit0d2b5532c417c58bd24e71a56c5c55b43e423a59 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/create.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
parent241326a9a8c20ad7f2bcf651416b836e7778e090 (diff)
downloadpodman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.gz
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.bz2
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.zip
Merge pull request #5852 from baude/v1prune
Podman V2 birth
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r--cmd/podman/create.go100
1 files changed, 0 insertions, 100 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
deleted file mode 100644
index 03eb1b09f..000000000
--- a/cmd/podman/create.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package main
-
-import (
- "fmt"
- "os"
- "strings"
-
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/pkg/adapter"
- "github.com/opentracing/opentracing-go"
- "github.com/pkg/errors"
- "github.com/sirupsen/logrus"
- "github.com/spf13/cobra"
-)
-
-var (
- createCommand cliconfig.CreateValues
- createDescription = `Creates a new container from the given image or storage and prepares it for running the specified command.
-
- The container ID is then printed to stdout. You can then start it at any time with the podman start <container_id> command. The container will be created with the initial state 'created'.`
- _createCommand = &cobra.Command{
- Use: "create [flags] IMAGE [COMMAND [ARG...]]",
- Short: "Create but do not start a container",
- Long: createDescription,
- RunE: func(cmd *cobra.Command, args []string) error {
- createCommand.InputArgs = args
- createCommand.GlobalFlags = MainGlobalOpts
- createCommand.Remote = remoteclient
- return createCmd(&createCommand)
- },
- Example: `podman create alpine ls
- podman create --annotation HELLO=WORLD alpine ls
- podman create -t -i --name myctr alpine ls`,
- }
-)
-
-func init() {
- createCommand.PodmanCommand.Command = _createCommand
- createCommand.SetHelpTemplate(HelpTemplate())
- createCommand.SetUsageTemplate(UsageTemplate())
- getCreateFlags(&createCommand.PodmanCommand)
- flags := createCommand.Flags()
- flags.AddFlagSet(getNetFlags())
- flags.SetInterspersed(false)
- flags.SetNormalizeFunc(aliasFlags)
-}
-
-func createCmd(c *cliconfig.CreateValues) error {
- if c.Bool("trace") {
- span, _ := opentracing.StartSpanFromContext(Ctx, "createCmd")
- defer span.Finish()
- }
-
- if c.String("authfile") != "" {
- if _, err := os.Stat(c.String("authfile")); err != nil {
- return errors.Wrapf(err, "error getting authfile %s", c.String("authfile"))
- }
- }
-
- if err := createInit(&c.PodmanCommand); err != nil {
- return err
- }
-
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
- if err != nil {
- return errors.Wrapf(err, "error creating libpod runtime")
- }
- defer runtime.DeferredShutdown(false)
-
- cid, err := runtime.CreateContainer(getContext(), c)
- if err != nil {
- return err
- }
- fmt.Printf("%s\n", cid)
- return nil
-}
-
-func createInit(c *cliconfig.PodmanCommand) error {
- if !remote && c.Bool("trace") {
- span, _ := opentracing.StartSpanFromContext(Ctx, "createInit")
- defer span.Finish()
- }
-
- if c.IsSet("privileged") && c.IsSet("security-opt") {
- logrus.Warn("setting security options with --privileged has no effect")
- }
-
- if (c.IsSet("dns") || c.IsSet("dns-opt") || c.IsSet("dns-search")) && (c.String("network") == "none" || strings.HasPrefix(c.String("network"), "container:")) {
- return errors.Errorf("conflicting options: dns and the network mode.")
- }
-
- // Docker-compatibility: the "-h" flag for run/create is reserved for
- // the hostname (see https://github.com/containers/libpod/issues/1367).
-
- if len(c.InputArgs) < 1 {
- return errors.Errorf("image name or ID is required")
- }
-
- return nil
-}