Skip to content
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

No write permissions when mounting local volumes with podman #251

Closed
pmtempy opened this issue Sep 30, 2021 · 5 comments
Closed

No write permissions when mounting local volumes with podman #251

pmtempy opened this issue Sep 30, 2021 · 5 comments

Comments

@pmtempy
Copy link

pmtempy commented Sep 30, 2021

I'm trying to run a rocker/rstudio:4.0.4 container in WSL2 Ubuntu 20.04 (using podman as my container tool) while mounting a local directory (my WSL home directory) into the container using the following command: podman run -e PASSWORD=password -p 8787:8787 -v $(pwd):/home/rstudio/my-project rocker/rstudio:4.0.4.

I can launch the container just fine, but whenever I try to write a file (e.g. modifying an existing script, creating a new project, etc.) I encounter the following error:

30 Sep 2021 13:59:59 [rsession-rstudio] ERROR system error 2 (No such file or directory) [path: /home/rstudio/my-project/test-file.r]; OCCURRED AT rstudio::core::Error rstudio::core::FilePath::openForWrite(std::shared_ptr<std::basic_ostream<char> >&, bool) const src/cpp/shared_core/FilePath.cpp:1482; LOGGED FROM: rstudio::core::Error rstudio::core::{anonymous}::openFileForWritingWithRetry(const rstudio::core::FilePath&, bool, int, std::shared_ptr<std::basic_ostream<char> >*) src/cpp/core/FileSerializer.cpp:73

If I try to mount the rstudio home directory directly, I cannot log into RStudio at all: podman run -e PASSWORD=password -p 8787:8787 -v $(pwd):/home/rstudio rocker/rstudio:4.0.4. The GUI shows an error prompt reading: "RStudio initialization error, unable to connect to service", and my container CLI shows: 30 Sep 2021 14:03:50 [rsession-rstudio] ERROR system error 13 (Permission denied) [path: /home/rstudio/.local/share/rstudio, target-dir: ]; OCCURRED AT rstudio::core::Error rstudio::core::FilePath::createDirectory(const string&) const src/cpp/shared_core/FilePath.cpp:809; LOGGED FROM: int main(int, char* const*) src/cpp/session/SessionMain.cpp:1961.

If I try to mount a normal Windows directory instead (podman run -e PASSWORD=password -p 8787:8787 -v /mnt/c/Users/user/Documents/:/home/rstudio localhost/custom-rstudio-rocker), everything seems to work fine.

I've played around with adding the root=TRUE parameter (described here: https://www.rocker-project.org/use/managing_users/#custom-usernames-and-user-ids), but that didn't solve the issue either. I also tried adding the z flag, as described by this SELinux issue, but that didn't help either. I don't think my Ubuntu WSL2 uses SELinux anyway?

I've encountered some other issues between WSL's file system and RStudio (a native install on host machine) before, namely while trying to knit an R bookdown project. The reason for this seems to be that the WSL file system acts like a network drive (\\\\wsl$\Ubuntu-20.04\home\user). I haven't been able to find a resolution to this problem either though, although if I recall correctly most discussions seemed to point to pandoc being the culprit, so I'm not sure if it's relevant at all here?

Any help would be much appreciated!

@eitsupi
Copy link
Member

eitsupi commented Sep 30, 2021

I think this is a Podman issue (rootless mode?), Not a WSL2 issue. I encourage you to look for information about Podman.

I have Docker Desktop for Windows installed and using rocker/rstudio on WSL2 and I don't have such issues.

@pmtempy
Copy link
Author

pmtempy commented Oct 1, 2021

Oh! The one variable I didn't test. Thanks a bunch @eitsupi ! I just installed the standard docker tool and can confirm that things seem to be working normally. Great! It's a shame that podman seems to be acting up in this rather strange way though.


I did notice a similar error when I tried (accidentally) binding to the default path in which WSL opens on my system (/mnt/c/Windows/system32), which makes sense since it'd be protected by Windows, just throwing that out here for anyone who might stumble upon this in the future. Logging into RStudio fails then and the ERROR system error 13 shows up in the CLI output again.


For the record, here are a bunch of threads discussing issues related to podman and rocker:

Lastly, in reply to @cboettig's question here: one of the motivations to use podman instead of docker is that the Docker Desktop app for Windows is no longer free to use in a commercial setting. While docker can still be installed natively in WSL without Docker Desktop, from my understanding it takes a bit more configuration to get it to work (i.e. there is no systemd, so you have to launch the service manually and keep it alive, create user groups yourself, etc.), whereas podman is a simple executable that can serve as a drop-in replacement for any (most?) docker commands.

@eitsupi
Copy link
Member

eitsupi commented Oct 1, 2021

From my point of view, if you are not concerned with Podman, it seems better to install Docker CE on Ubuntu etc. on WSL2.
I haven't tried it myself, but installing Docker CE on Linux running on WSL2 is an alternative that is also mentioned in the Docker documentation.

https://www.docker.com/pricing/faq

Can I just install the Docker CLI instead of using Docker Desktop?
If you use a Mac, you can install Docker CLI and Engine inside a virtual machine, using VirtualBox or VMware Fusion for example, which may require purchasing a license for VirtualBox or VMware Fusion. On Windows you could install and run Docker CLI and Engine inside WSL2. If you use a Linux machine you can easily use the Docker CLI and Docker Engine, See the documentation on installing Docker Engine for instructions. Docker Desktop is not yet available for Linux.

@pmtempy
Copy link
Author

pmtempy commented Oct 1, 2021

Thanks for the info! Installing the engine on WSL2 is what I did now, but the caveats I mentioned above do apply. E.g. the service doesn't start automatically because there's no systemd, so you have to run dockerd in the background yourself when you launch WSL (which unfortunately isn't mentioned in docker's documentation as far as I can tell). Granted, this info can be found elsewhere and you can probably script around it as well, and the same goes for the user groups you might need to configure. So for my usage it currently works, but I can see why some people might prefer podman (especially since it's supposed to be a transparent replacement for docker containers ;) ).

@eitsupi
Copy link
Member

eitsupi commented Oct 2, 2021

Anyway, I think this issue is not specific to WSL2 but due to the handling of Podman's volume permissions. I recommend changing the title of the issue.

With a little search, you may find out about those solutions like these.
https://www.tutorialworks.com/podman-rootless-volumes/
https://www.redhat.com/sysadmin/debug-rootless-podman-mounted-volumes

@pmtempy pmtempy changed the title Mounting local volumes in WSL2 file system No write permissions when mounting local volumes with podman Oct 5, 2021
@pmtempy pmtempy closed this as completed Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants