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

Conversation

andyneff
Copy link
Contributor

The way the current script was written, if you have a when you do singularity run myimage.sif foo bar and the docker had a CMD defined, the singularity runscript will run CMD foo bar instead of foo bar. It should only run CMD when no command args are specified, to match docker and singularity build myimage.sif docker://myorg/myimage behavior.

If you accept this PR, what is the best way to get it into the other version branches? Do I need to create a PR to each branch version, or is that something the owners take care of?

Signed-off-by: Andy Neff <andy@visionsystemsinc.com>
@vsoch
Copy link
Member

vsoch commented Oct 16, 2019

There was a lot of contention around this (see #49) so I'm going to ask for @rgov input before making any changes. Generally we need to respect both CMD and ENTRYPOINT and account for all the cases of having / not having each defined (which I think the current implementation does).

@andyneff
Copy link
Contributor Author

Just as another data point, when I ran singularity build redis.sif docker://redis and look at the runscript, I see

# ENTRYPOINT and CMD - run ENTRYPOINT with CMD as default args
# override with user provided args
if [ $# -gt 0 ]; then
    SINGULARITY_OCI_RUN="${OCI_ENTRYPOINT} ${CMDLINE_ARGS}"
else
    SINGULARITY_OCI_RUN="${OCI_ENTRYPOINT} ${OCI_CMD}"
fi

Which agrees with my PR and docker's behavior

@rgov
Copy link

rgov commented Oct 16, 2019

@andyneff is correct:

If the image also specifies an ENTRYPOINT [in the Dockerfile] then the CMD [in the Dockerfile] or COMMAND [from the command line] get appended as arguments to the ENTRYPOINT.

@rgov
Copy link

rgov commented Oct 16, 2019

However, is the assignment of SINGULARITY_OCI_RUN safe here? What does it do to arguments that contain spaces, quotes, escaping, etc?

Edit: Ok I understand, this is going in the other direction.

@andyneff
Copy link
Contributor Author

@rgov that was a snippet from the other way to create singularity images from docker. I believe it has already properly quote escaped the string, and then eval set's it, so that they are set back to the the command line arguments $1 $2 ..., then finally exec $@

I was just using that as evidence for this PR, saying this should do what singularity build already does, as it is what is "expected behavior" for docker images/community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants