diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-05 14:48:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-05 14:48:28 +0200 |
commit | d1aaf3362204f860267e2bb58ec419b25edc5800 (patch) | |
tree | 9bad0c5881a7a64635543dec8d037afe66121f9e /libpod/container_internal_linux.go | |
parent | 7a7c8e9911c17e4e1748bbf81ab4df27c78426ab (diff) | |
parent | 21421c841159f861dfdfed14d9e0f226a5884cf0 (diff) | |
download | podman-d1aaf3362204f860267e2bb58ec419b25edc5800.tar.gz podman-d1aaf3362204f860267e2bb58ec419b25edc5800.tar.bz2 podman-d1aaf3362204f860267e2bb58ec419b25edc5800.zip |
Merge pull request #7176 from mheon/make_entrypoint
Ensure WORKDIR from images is created
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 4cfe992ea..9fb9738dc 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -159,7 +159,32 @@ func (c *Container) prepare() error { } // Save changes to container state - return c.save() + if err := c.save(); err != nil { + return err + } + + // Ensure container entrypoint is created (if required) + if c.config.CreateWorkingDir { + workdir, err := securejoin.SecureJoin(c.state.Mountpoint, c.WorkingDir()) + if err != nil { + return errors.Wrapf(err, "error creating path to container %s working dir", c.ID()) + } + rootUID := c.RootUID() + rootGID := c.RootGID() + + if err := os.MkdirAll(workdir, 0755); err != nil { + if os.IsExist(err) { + return nil + } + return errors.Wrapf(err, "error creating container %s working dir", c.ID()) + } + + if err := os.Chown(workdir, rootUID, rootGID); err != nil { + return errors.Wrapf(err, "error chowning container %s working directory to container root", c.ID()) + } + } + + return nil } // cleanupNetwork unmounts and cleans up the container's network |