Description
Feature request description
As is, the parsing of image mount is (inexplicably?) different from other mount options, in that you cannot pass arguments, as, instead of using parseMountOptions, like glob, bind, tmpfs, ramfs, and volume mounts, it has it's own parsing rules like devpts.
Unlike devpts, image mounts are not a specialised filesystem, they are (according to the docs) just bind mounts, so, there is a disparity between --mount type=bind
and --mount type=image
.
There is no way to, for example, mount an image as noexec.
Suggest potential solution
Experimentally butchering podman's code does show that it supports mount options for image mounts:
var overlayMount spec.Mount
if volume.ReadWrite {
overlayMount, err = overlay.Mount(contentDir, imagePath, volume.Dest, c.RootUID(), c.RootGID(), c.runtime.store.GraphOptions())
} else {
overlayMount, err = overlay.MountReadOnly(contentDir, imagePath, volume.Dest, c.RootUID(), c.RootGID(), c.runtime.store.GraphOptions())
}
if err != nil {
return nil, nil, fmt.Errorf("creating overlay mount for image %q failed: %w", volume.Source, err)
}
+ overlayMount.Options = append(overlayMount.Options, volume.Options...)
g.AddMount(overlayMount)
(not showing propagating options through, but it's a copy paste of how other images do it)
Building and running podman does show that it works:
$ podman run --rm -it --security-opt=no-new-privileges --mount type=volume,source=data,target=/data,noexec --read-only --read-only-tmpfs=false --mount type=image,source=out,subpath=/var/lib/neo4j/conf,target=/var/lib/neo4j/conf,noexec=true --entrypoint /bin/bash out
neo4j@44f157292898:~$ mount | grep /var/lib/neo4j/conf
/home/hidden/.local/share/containers/storage/overlay-containers/44f1572928982bb238596fff941527eaf0b185d1d785dac11bfe9d3e115dfbe4/userdata/overlay/3189830976/merge on /var/lib/neo4j/conf type overlay (rw,noexec,relatime,lowerdir=/run/user/1000/containers/overlay-containers/44f1572928982bb238596fff941527eaf0b185d1d785dac11bfe9d3e115dfbe4/userdata/subpath1552514941,upperdir=/home/hidden/.local/share/containers/storage/overlay-containers/44f1572928982bb238596fff941527eaf0b185d1d785dac11bfe9d3e115dfbe4/userdata/overlay/3189830976/upper,workdir=/home/hidden/.local/share/containers/storage/overlay-containers/44f1572928982bb238596fff941527eaf0b185d1d785dac11bfe9d3e115dfbe4/userdata/overlay/3189830976/work,userxattr)
I don't feel experienced enough with podman's codebase to push a pull request just yet, sorry.
Have you considered any alternatives?
Since this is a container that isn't supposed to have any privileges on the inside, remounting is not an option, I don't understand bind mounts sufficiently to mount an image manually via a --mount type=bind, although I assume it would work.
Additional context
No response