summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-05-07 15:17:33 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-05-15 03:56:38 -0400
commitb75bb4665e1c4db2bb3b931af04c099deec0f666 (patch)
treedbecc2cb2496eb02faa8733ce43cc8c013cb9800 /libpod/container_internal.go
parentfabaa256676d3cfb611f89922ccaf3405718a6f0 (diff)
downloadpodman-b75bb4665e1c4db2bb3b931af04c099deec0f666.tar.gz
podman-b75bb4665e1c4db2bb3b931af04c099deec0f666.tar.bz2
podman-b75bb4665e1c4db2bb3b931af04c099deec0f666.zip
Create the /etc/mtab file if does not exists
We should create the /etc/mtab->/proc/mountinfo link so that mount command will work within the container. Docker does this by default. Fixes: https://github.com/containers/podman/issues/10263 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 53b85a466..9af652409 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1530,6 +1530,16 @@ func (c *Container) mountStorage() (_ string, deferredErr error) {
}()
}
+ // If /etc/mtab does not exist in container image, then we need to
+ // create it, so that mount command within the container will work.
+ mtab := filepath.Join(mountPoint, "/etc/mtab")
+ if err := os.MkdirAll(filepath.Dir(mtab), 0755); err != nil {
+ return "", errors.Wrap(err, "error creating mtab directory")
+ }
+ if err = os.Symlink("/proc/mounts", mtab); err != nil && !os.IsExist(err) {
+ return "", err
+ }
+
// Request a mount of all named volumes
for _, v := range c.config.NamedVolumes {
vol, err := c.mountNamedVolume(v, mountPoint)