I have a dockerfile which ends
ENTRYPOINT ["sh"]
CMD ["runscript.sh"]
I can run docker with an argument (a shell script) that overrides "runscript.sh" (if i wish). Note: the shell scripts are provided by a --bind
mount
I am translating my Dockerfile to a Singularity recipe. From my understanding i can replicate this ENTRYPOINT/CMD functionality using the "%startscript" label. I am trying:
%startscript
exec "$@"
then run an instance of the container using
singularity instance start --bind /hostpath:/containerpath model.sif instancename script.sh
When i do this i get the message:
/.singularity.d/startscript: 4: exec: script.sh: not found
I know i am doing this all wrong, but cant seem to work out what.
Note: if i replace exec "$@"
with ./script.sh
then the script is executed but i am limited to having a script with this name. I want the flexibility to pass any named script.
You need to use
%runscript
and not
%startscript
Then you can pass an argument to run command which will be used in place of the default value in the recipe,
singularity exec image argument
eg. in the recipe file
%runscript
./runscript.sh
then use either
singularity exec image.sif
or
singularity exec image.sif newscript.sh
depending on whether you want to run the default container script or the "newscript"