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

Make the CMD behave more like docker #80

Open
wants to merge 1 commit into
base: v3.4.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docker2singularity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,15 @@ if [[ $WORKINGDIR != '""' ]]; then
fi

# First preference goes to both entrypoint / cmd, then individual
if [ -n "$ENTRYPOINT" ] && [ -n "$CMD" ]; then
echo exec "$ENTRYPOINT" "$CMD" '"$@"' >> $build_sandbox/.singularity.d/runscript;
if [ -n "$CMD" ]; then
echo 'if [ $# = 0 ]; then' >> $build_sandbox/.singularity.d/runscript
# Only add the entrypoint if it's not null
echo \ \ exec ${ENTRYPOINT:+"$ENTRYPOINT"} "$CMD" >> $build_sandbox/.singularity.d/runscript;
echo "else" >> $build_sandbox/.singularity.d/runscript
echo \ \ exec ${ENTRYPOINT:+"$ENTRYPOINT"} '"$@"' >> $build_sandbox/.singularity.d/runscript;
echo "fi" >> $build_sandbox/.singularity.d/runscript
elif [ -n "$ENTRYPOINT" ]; then
echo exec "$ENTRYPOINT" '"$@"' >> $build_sandbox/.singularity.d/runscript;
elif [ -n "$CMD" ]; then
echo exec "$CMD" '"$@"' >> $build_sandbox/.singularity.d/runscript;
fi

chmod +x $build_sandbox/.singularity.d/runscript;
Expand Down