Reputation: 157
I have a problem with Docker. I have made a Singularity image file, it has a runscript that needs some args in order to work. These are the very first lines of this script:
#!/bin/sh
FS=' ' read -r -a array <<< "$@"
etc etc...
I had to convert it into a Docker image, I have used singularity2docker to do that. I tried to launch it without any arguments (a simple docker run -it containername), I can see that the runscript is executed but, of course, it doesn't work properly due to the lack of the parameters. If I try to add them (docker run -it containername "-t arg1 -n arg2") I get
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-t\": executable file not found in $PATH": unknown.
I am kinda sure there's some silly reason for that, probably due to the singularity2docker conversion. I can easily access the sandbox used to build the Docker image but I really have no clue about what to do. Here's the Dockerfile I can find inside.
FROM scratch
ADD . /
ENV LD_LIBRARY_PATH /.singularity.d/libs
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LABEL "org.label-schema.build-date" "Fri,_20_Apr_2018_14:42:15_+0000"
LABEL "org.label-schema.build-size" "1374MB"
LABEL "org.label-schema.schema-version" "1.0"
LABEL "org.label-schema.usage.singularity.deffile" "test1.def"
LABEL "org.label-schema.usage.singularity.deffile.bootstrap" "docker"
LABEL "org.label-schema.usage.singularity.deffile.from" "centos:7"
LABEL "org.label-schema.usage.singularity.version" "2.4.4-dist"
CMD ["/bin/bash", "run_singularity2docker.sh"]
I guess that trying to set up an ENTRYPOINT might work but I am not even sure if and how I can do it using that temp sandbox..
Any help would be appreciated, thank you.
Upvotes: 1
Views: 1794
Reputation: 264641
Switch this around to use an entrypoint. The command value is overridden by anything you pass after the image name. The value of the command is appended to the entrypoint if you define one.
First switch your script to use bash in the first line:
#!/bin/bash
FS=' ' read -r -a array <<< "$@"
etc etc...
Then update your Dockerfile to use an entrypoint:
FROM scratch
ADD . /
ENV LD_LIBRARY_PATH /.singularity.d/libs
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LABEL "org.label-schema.build-date" "Fri,_20_Apr_2018_14:42:15_+0000"
LABEL "org.label-schema.build-size" "1374MB"
LABEL "org.label-schema.schema-version" "1.0"
LABEL "org.label-schema.usage.singularity.deffile" "test1.def"
LABEL "org.label-schema.usage.singularity.deffile.bootstrap" "docker"
LABEL "org.label-schema.usage.singularity.deffile.from" "centos:7"
LABEL "org.label-schema.usage.singularity.version" "2.4.4-dist"
ENTRYPOINT ["/bin/bash", "run_singularity2docker.sh"]
Then run your command without quoting the arguments to pass them each as separate args to your entrypoint script:
docker run -it containername -t arg1 -n arg2
Upvotes: 1