-
Notifications
You must be signed in to change notification settings - Fork 629
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
envWhitelist not working with docker.sudo = true
#5309
Comments
This is the nfx_launch command that it created
as you can see the |
this seems to be a docker limitation? |
@pditommaso no we just have to compose the nxf_launch() {
sudo NXF_TASK_WORKDIR="$NXF_TASK_WORKDIR" AVARTHATSHOULDTOTALLYBETHERE="$AVARTHATSHOULDTOTALLYBETHERE" docker run -i --cpu-shares 1024 -e "NXF_TASK_WORKDIR" -e "AVARTHATSHOULDTOTALLYBETHERE" -v /tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97:/tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97 -w "$NXF_TASK_WORKDIR" --name "$NXF_BOXID" ubuntu /bin/bash -ue /tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97/.command.sh
} instead of this nxf_launch() {
sudo docker run -i --cpu-shares 1024 -e "NXF_TASK_WORKDIR" -e "AVARTHATSHOULDTOTALLYBETHERE" -v /tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97:/tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97 -w "$NXF_TASK_WORKDIR" --name $NXF_BOXID ubuntu /bin/bash -ue /tmp/test-nf/work/aa/de499a28fb8da7677d285fc3941f97/.command.sh
} and of course do the same thing in any other place where we do the same thing with sudo and the docker cli. |
This comment was marked as outdated.
This comment was marked as outdated.
Got it, the variable must be passed before the |
Bug report
Expected behavior and actual behavior
When running nextflow with
docker.sudo=true
and any env var inenvWhitelist
I expect the env vars to be available inside the process containers, however they are not, see additional context for more details.Steps to reproduce the problem
Open your nextflow config and write
Now run this pipeline
Program output
Environment
nextflow version 24.04.4.5917
Linux 6.8.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Tue Aug 13 13:35:26 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
zsh 5.9 (x86_64-ubuntu-linux-gnu)
Additional context
As a best practice, when you install the Docker daemon the installation process suggests you to not allow access to
/var/run/docker.sock
to your otherwise unprivileged user on the machine. This is because when a user gets added to thedocker
group it essentially becomes root since things like this can be donedocker run -it --privileged --net=host --pid=host debian nsenter -t 1 -n -m -p
.Following this best practice, one can configure Nextflow to ask for privileges when running docker in this way:
This works well indeed, however when used in combination with
docker.envWhitelist
. Why? BecauseenvWhitelist
will share the environment variables with the shell that is starting the sudo command here but the finaldocker run
command does not get the env vars in its/proc/self/environ
because they are not automatically passed down bysudo
. A possible solution to this problem is to run withsudo -E
, however a safer approach would be to forward only the whitelisted env vars.The text was updated successfully, but these errors were encountered: