diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-04-26 17:21:48 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-15 14:53:18 +0000 |
commit | 7bdfb4f9b361aca4f4f3337907feb3ca414d36e4 (patch) | |
tree | aff63093af49df79820e72a5a68f07e6fe70b863 /cmd/podman/run.go | |
parent | 4b4de5dc21f034f5f678114dbf6d51f047c96a59 (diff) | |
download | podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.gz podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.bz2 podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.zip |
podman: accept option --rootfs to use exploded images
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #871
Approved by: mheon
Diffstat (limited to 'cmd/podman/run.go')
-rw-r--r-- | cmd/podman/run.go | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 3e7dc2303..2131df7ab 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -14,6 +14,7 @@ import ( "github.com/projectatomic/libpod/cmd/podman/libpodruntime" "github.com/projectatomic/libpod/libpod" "github.com/projectatomic/libpod/libpod/image" + "github.com/projectatomic/libpod/pkg/inspect" cc "github.com/projectatomic/libpod/pkg/spec" "github.com/projectatomic/libpod/pkg/util" "github.com/sirupsen/logrus" @@ -66,25 +67,36 @@ func runCmd(c *cli.Context) error { return errors.Wrapf(err, "error creating libpod runtime") } defer runtime.Shutdown(false) + if len(c.Args()) < 1 { return errors.Errorf("image name or ID is required") } + rootfs := "" + if c.Bool("rootfs") { + rootfs = c.Args()[0] + } + ctx := getContext() rtc := runtime.GetConfig() - newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) - if err != nil { - return errors.Wrapf(err, "unable to find image") - } - data, err := newImage.Inspect(ctx) - if err != nil { - return err - } - if len(newImage.Names()) < 1 { - imageName = newImage.ID() - } else { - imageName = newImage.Names()[0] + var newImage *image.Image = nil + var data *inspect.ImageData = nil + if rootfs == "" { + newImage, err = runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) + if err != nil { + return errors.Wrapf(err, "unable to find image") + } + + data, err = newImage.Inspect(ctx) + if err != nil { + return err + } + if len(newImage.Names()) < 1 { + imageName = newImage.ID() + } else { + imageName = newImage.Names()[0] + } } createConfig, err := parseCreateOpts(ctx, c, runtime, imageName, data) if err != nil { @@ -112,6 +124,9 @@ func runCmd(c *cli.Context) error { options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize)) options = append(options, libpod.WithGroups(createConfig.GroupAdd)) options = append(options, libpod.WithIDMappings(*createConfig.IDMappings)) + if createConfig.Rootfs != "" { + options = append(options, libpod.WithRootFS(createConfig.Rootfs)) + } // Default used if not overridden on command line |