aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/run.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-18 12:05:06 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-03 12:38:18 +0000
commit00d38cb37958f3c636aa5837b8f01dfad891a0b5 (patch)
treee0eb9039266a725f5315ac05f3909f7a6a4a309e /cmd/podman/run.go
parent8aeb38e4a718925a78606b8aa014bce6b4a4054c (diff)
downloadpodman-00d38cb37958f3c636aa5837b8f01dfad891a0b5.tar.gz
podman-00d38cb37958f3c636aa5837b8f01dfad891a0b5.tar.bz2
podman-00d38cb37958f3c636aa5837b8f01dfad891a0b5.zip
podman create/run need to load information from the image
We should be pulling information out of the image to set the defaults to use when setting up the container. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #110 Approved by: mheon
Diffstat (limited to 'cmd/podman/run.go')
-rw-r--r--cmd/podman/run.go59
1 files changed, 14 insertions, 45 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index bc93459ad..654b7a47e 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -1,9 +1,8 @@
package main
import (
+ "encoding/json"
"fmt"
- "io"
- "os"
"sync"
"github.com/pkg/errors"
@@ -26,7 +25,6 @@ var runCommand = cli.Command{
}
func runCmd(c *cli.Context) error {
- var imageName string
if err := validateFlags(c, createFlags); err != nil {
return err
}
@@ -41,51 +39,10 @@ func runCmd(c *cli.Context) error {
return err
}
- createImage := runtime.NewImage(createConfig.Image)
- createImage.LocalName, _ = createImage.GetLocalImageName()
- if createImage.LocalName == "" {
- // The image wasnt found by the user input'd name or its fqname
- // Pull the image
- var writer io.Writer
- if !createConfig.Quiet {
- writer = os.Stdout
- }
- createImage.Pull(writer)
- }
-
runtimeSpec, err := createConfigToOCISpec(createConfig)
if err != nil {
return err
}
- logrus.Debug("spec is ", runtimeSpec)
-
- if createImage.LocalName != "" {
- nameIsID, err := runtime.IsImageID(createImage.LocalName)
- if err != nil {
- return err
- }
- if nameIsID {
- // If the input from the user is an ID, then we need to get the image
- // name for cstorage
- createImage.LocalName, err = createImage.GetNameByID()
- if err != nil {
- return err
- }
- }
- imageName = createImage.LocalName
- } else {
- imageName, err = createImage.GetFQName()
- }
- if err != nil {
- return err
- }
- logrus.Debug("imageName is ", imageName)
-
- imageID, err := createImage.GetImageID()
- if err != nil {
- return err
- }
- logrus.Debug("imageID is ", imageID)
options, err := createConfig.GetContainerCreateOptions()
if err != nil {
@@ -93,8 +50,10 @@ func runCmd(c *cli.Context) error {
}
// Gather up the options for NewContainer which consist of With... funcs
- options = append(options, libpod.WithRootFSFromImage(imageID, imageName, false))
+ options = append(options, libpod.WithRootFSFromImage(createConfig.ImageID, createConfig.Image, true))
options = append(options, libpod.WithSELinuxLabels(createConfig.ProcessLabel, createConfig.MountLabel))
+ options = append(options, libpod.WithLabels(createConfig.Labels))
+ options = append(options, libpod.WithUser(createConfig.User))
options = append(options, libpod.WithShmDir(createConfig.ShmDir))
ctr, err := runtime.NewContainer(runtimeSpec, options...)
if err != nil {
@@ -107,6 +66,16 @@ func runCmd(c *cli.Context) error {
}
logrus.Debugf("container storage created for %q", ctr.ID())
+ createConfigJSON, err := json.Marshal(createConfig)
+ if err != nil {
+ return err
+ }
+ if err := ctr.AddArtifact("create-config", createConfigJSON); err != nil {
+ return err
+ }
+
+ logrus.Debug("new container created ", ctr.ID())
+
if c.String("cidfile") != "" {
libpod.WriteFile(ctr.ID(), c.String("cidfile"))
return nil