Skip to content

Commit

Permalink
Make the CMD behave more like docker
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Neff <[email protected]>
  • Loading branch information
andyneff committed Oct 16, 2019
1 parent d5a96e9 commit 07e954d
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit 07e954d

Please sign in to comment.