Docker container fails when running with host user (-u
)
#175
Labels
enhancement
New feature or request
-u
)
#175
I'll try to explain the problem to the best of my ability:
Per default, the user in a Docker container is
root
. This entails that any files created in mounted directories by commands run in the container are owned byroot
and can only be read by other users, not written to. To get around this, many people are adding-u $(id -u)
to theirdocker run
command.However, this user does not exist in the container and thus does not have a default shell. The container will therefore fall back to using
/bin/sh
. Crucially, the env variableSHELL
is set at this stage and, as you might be aware, shells don't setSHELL
themselves (SHELL
is set on login; i.e. if you startbash
from another shell it won't setSHELL
to/bin/bash
; it will just inherit theSHELL
env variable from the previous shell; you can test this by runningSHELL=bla bash -c 'echo $SHELL'
). Taken together, this means that, when the user runsthey will get the following error:
This is because the following happens:
sh
since there is no default shell for the user$(id -u)
; this setsSHELL
to/bin/sh
/opt/bin/run_clair3.sh
is run bybash
, butSHELL
is still/bin/sh
run_clair3.sh
you use${SHELL}
to invoke/opt/bin/scripts/clair3_c_impl.sh
Clair3/run_clair3.sh
Line 346 in 21e7ead
/opt/bin/scripts/clair3_c_impl.sh
is run by/bin/sh
which lacks thebash
built-inreadarray
and thus failsTo fix this, I would suggest calling
${SCRIPT_PATH}/scripts/${CLAIR3_SCRIPT}
without${SHELL}
(i.e. just${SCRIPT_PATH}/scripts/${CLAIR3_SCRIPT} ... options ...
since the other scripts all have shebang lines anyway.The text was updated successfully, but these errors were encountered: