'Nextflow with Docker -- Problem with permission rights in WSL2
On WSL2 I am running the below Nextflow process via:
script.nf -with-docker memesuite/memesuite:latest
Outcome:
Command error:
.command.sh: line 2: foo.txt: Permission denied
…but only when running on WSL2, not on a "pure" Linux machine and also not on macOS. If I access that container manually (docker run -it) in WSL2 I have to add --user root to be allowed to save anything to the WSL2 filesystem. What do I have to tell Nextflow to be able to publish to the WSL2 filesystem with the Docker profile?
The Nextflow process
#! /usr/bin/env nextflow
nextflow.enable.dsl=2
process A {
publishDir launchDir, mode: 'move'
output:
path("foo.txt")
script:
"""
echo '123' > foo.txt
"""
}
workflow { A() }
Solution 1:[1]
You might need to play around with some of the docker scope config options, but, to answer your immediate question, you might need something like this in your nextflow.config:
docker {
enabled = true
runOptions = '--user root'
}
Or perhaps:
docker {
enabled = true
sudo = true
}
However, I wouldn't have expected you to need the above unless your container needs elevated privileges to run (which I don't think it does). I am not familiar with WSL2 at all, but I suspect you might just need to add your user to the docker group, creating it if necessary. Not sure if you have seen or followed the post install docs, but doing so might be helpful here:
- Create the docker group.
sudo groupadd docker
- Add your user to the docker group.
sudo usermod -aG docker $USER
- Log out and log back in so that your group membership is re-evaluated.
If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.
On Linux, you can also run the following command to activate the changes to groups:
newgrp docker
- Verify that you can run docker commands without sudo.
docker run hello-world
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve |
