-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Podman + runc: Cannot mount read-only filesystem on host as a volume #12205
Comments
mounting "/home/anders/lima/hello" to rootfs at "/hello" caused: operation not permitted: OCI permission denied
I recall seeing similar things on RHEL, which turned out to be a too-old |
Could be a bug in the podman packaging then, currently it says " And if course runc is a system package, so that means that it is stuck on OS (currently runc 1.0.1) But I will try uninstall EDIT: Nope, same issue also with runc 1.0.2 (latest) ? |
If this is a runc issue, it should be opened over their. If this is a runc version issue, then Podman upstream can not fix. Is there anything upstream Podman can do to fix this, then we need to close the issue. (We are in bugfix mode and need to get our issues under 200.) :^) |
It's possible to use docker with runc, and podman with crun. Just not podman with runc, which might be expected ? Something about the fuse-mounted directory, that makes it fail the mount when podman tries to make the OCI do it.
This was rootless containers under cgroups v2, it did work if you used |
Update: I still think this is a Would be interesting to see an OCI spec from Docker/Containerd vs one from Podman. Fix is probably still in runc but knowing that exactly is causing it to blow up would help a lot. |
You should be able to duplicate this on your own machine, by using the "docker" and "podman" example files. https://github.com/lima-vm/lima/tree/master/examples |
@mheon : It turned out to be very simple, podman was trying to mount the read-only file system as rw podman {
"destination": "/hello",
"type": "bind",
"source": "/home/anders/lima/hello",
"options": [
"rw",
"rprivate",
"nosuid",
"nodev",
"rbind"
]
}, docker {
"destination": "/hello",
"type": "bind",
"source": "/home/anders/lima/hello",
"options": [
"rbind",
"rprivate",
"nosuid",
"ro",
"nodev"
]
}, Changing the volume mapping to |
That definitely seems like a bug - concur we should detect this. I'll rename the issue. |
mounting "/home/anders/lima/hello" to rootfs at "/hello" caused: operation not permitted: OCI permission denied
it works for root:
but not for user:
|
The way crun implemented it is to first try the mount, and if it fails then check the mount options for the source and attempt again with How to check it beforehand? Does docker adds |
@afbjorklund does it work if you run it as |
Adding an explicit Running with root also "worked". |
That is my understanding: if !m.Writable {
opts = append(opts, "ro")
} https://github.com/moby/moby/blob/20.10/daemon/oci_linux.go#L640 |
Anyway, switched over to export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y podman crun From the comments above, it seems like podman could add the "ro" instead of "crun". Here was the crun only fix: |
We're not using crun as the default in Ubuntu already? That's news to me. |
The depends line in deb is: Default: runc The requires line in rpm is:
Default: crun If you want "the other", you have to add it to the installation:
|
Tried to repro this with Was able to reproduce with fuse-sshfs. Was not able to reproduce with
So, for some reason, this is really specific to fuse. Maybe a bug in fuse? |
It was seen when running podman under lima. It mounts the home directory read-only (reverse sshfs) by default. It has been "fixed", by changing from runc to crun. Leaving the other one to be used only with nerdctl and docker. |
On the command line we use |
What runtime does is a bind mount, so it does not really matter if this is a fuse mount or not. Anyway, I am fixing this in runc (and the most complicated part is writing a test case). |
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case is added, which fails without the fix. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case (which was kind of hard to write) is added, and it fails without the fix. Note that rootless user need to be able to ssh to rootless@localhost in order to sshfs to work -- amend setup scripts to make it work. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
@afbjorklund can you test the fix? opencontainers/runc#3283 (You can get the static binary by navigating to Checks -> validate, when at the very bottom of the page under "Artifacts" you'll find "release-NNNNN" file which contains pre-built binaries). |
I also suffer from a similar issue when I try to mount volumes between my mac machine and the podman vm
|
@cmoulliard this issue is about podman + runc inability to bind-mount a read-only fuse mount to a container (because podman do es not add What you see is a different and most probably unrelated issue; please feel free to file a separate bug. |
@cmoulliard Note that the containers mount files on the VM, so you need to have some remote filesystem (like 9p or sshfs) mounted if you want to access files on your host. You can check the available files with Due to a limitation in CoreOS (i.e. read-only), it is not possible to mount at the path |
@kolyshkin : I can confirm that this new opencontainers/runc@d7846bc (actual commit, as per PR) opencontainers/runc@ecf09297 (merge commit, per binary) working:
ubuntu: (not working)
Validated by creating a lima VM with podman.yaml, and then installing and selecting "runc" as the engine in the config
|
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case (which was kind of hard to write) is added, and it fails without the fix. Note that rootless user need to be able to ssh to rootless@localhost in order to sshfs to work -- amend setup scripts to make it work, and skip the test if the setup is not working. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case (which was kind of hard to write) is added, and it fails without the fix. Note that rootless user need to be able to ssh to rootless@localhost in order to sshfs to work -- amend setup scripts to make it work, and skip the test if the setup is not working. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case (which was kind of hard to write) is added, and it fails without the fix. Note that rootless user need to be able to ssh to rootless@localhost in order to sshfs to work -- amend setup scripts to make it work, and skip the test if the setup is not working. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]>
So is this fixed in upstream runc? Or is this something we need to fix in Podman, or can I close this issue? |
Once the new runc has been released, it will work with the current Podman and the Until then, one has to use crun since the current runc only works with Docker and its Currently this mostly affected lima users, but an update has been pushed there... Unless some other project (including Podman Machine) also starts using sshfs volumes ? |
Ok I am going to close this issue, since it is not a issue that Podman can fix. Although I guess we could update the spec file to require the latest runc once it is released. |
Current ETA is runc 1.1.0 |
As reported in [1], in a case where read-only fuse (sshfs) mount is used as a volume without specifying ro flag, the kernel fails to remount it (when adding various flags such as nosuid and nodev), returning EPERM. Here's the relevant strace line: > [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted) I was not able to reproduce it with other read-only mounts as the source (tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this might be specific to fuse. The fix is to check whether the source has RDONLY flag, and retry the remount with this flag added. A test case (which was kind of hard to write) is added, and it fails without the fix. Note that rootless user need to be able to ssh to rootless@localhost in order to sshfs to work -- amend setup scripts to make it work, and skip the test if the setup is not working. [1] containers/podman#12205 Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit 50105de) Conflicts: - .cirrus.yml: trivial, due to missing commit f0dbefa. - .github/workflows/test.yml: due to missing commits 120f740 and 3fd1851, resolved manually. - Dockerfile: trivial, due to missing commit 24d318b. - libcontainer/rootfs_linux.go: due to missing commits 36aefad and 9c44407, resolved manually. Signed-off-by: Kir Kolyshkin <[email protected]>
I did a backport for runc 1.0.3, too, which might come before 1.1.0. |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Trying to use rootless containers on ubuntu 21.10 with podman 3.2.1 using the default "runc" fails.
Installing "crun" makes it work again, with runc the volume mounts are failing (OCI permission denied)
Steps to reproduce the issue:
limactl start examples/podman.yaml
export CONTAINER_HOST=unix://$HOME/podman.sock
podman --remote run -it -v $PWD/hello:/hello docker.io/busybox cat /hello/world
Describe the results you received:
Error: error preparing container e552b677afd051af9dccb902ea038e527445a5daa1d08d59623364907700d497 for attach: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/home/anders/lima/hello" to rootfs at "/hello" caused: operation not permitted: OCI permission denied
Describe the results you expected:
Hello, World!
Additional information you deem important (e.g. issue happens only occasionally):
It works after installing
crun
, it fails with onlyrunc
(which is the apt default)Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
Ubuntu 21.10
https://packages.ubuntu.com/impish/podman
https://packages.ubuntu.com/impish/runc
The text was updated successfully, but these errors were encountered: