summaryrefslogtreecommitdiff
path: root/cmd/podman/create.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r--cmd/podman/create.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 586368e24..04f3cd9e6 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -99,6 +99,10 @@ func createCmd(c *cli.Context) error {
storageOpts.UIDMap = mappings.UIDMap
storageOpts.GIDMap = mappings.GIDMap
+ if os.Getuid() != 0 {
+ rootless.SetSkipStorageSetup(true)
+ }
+
runtime, err := libpodruntime.GetRuntimeWithStorageOpts(c, &storageOpts)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
@@ -110,7 +114,7 @@ func createCmd(c *cli.Context) error {
imageName := ""
var data *inspect.ImageData = nil
- if rootfs == "" {
+ if rootfs == "" && !rootless.SkipStorageSetup() {
newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
if err != nil {
return err
@@ -133,6 +137,14 @@ func createCmd(c *cli.Context) error {
return err
}
+ became, ret, err := joinOrCreateRootlessUserNamespace(createConfig, runtime)
+ if err != nil {
+ return err
+ }
+ if became {
+ os.Exit(ret)
+ }
+
ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return err