Running java in singularity

1,179 views
Skip to first unread message

Sheena T

unread,
Jul 14, 2017, 6:47:20 PM7/14/17
to singu...@lbl.gov
I'm trying to setup singularity (2.3.1) containers for various java programs. I'm building docker (17.05.0-ce) images, then exporting the image and importing to singularity. The image works in docker, but I can't figure out how to make it work in singularity.

FROM anapsix/alpine-java:jdk7

# Must update ssl to use wget on alpine
RUN   apk update
\
     
&&   apk add ca-certificates wget \
     
&&   update-ca-certificates

ENV PICARD_INSTALL_DIR
=/opt
ENV version 1.113

RUN wget http:/
/sourceforge.net/projects/picard/files/picard-tools/${version}/picard-tools-${version}.zip && \
    unzip picard
-tools-${version}.zip && \
    cp picard
-tools-${version}/*jar $PICARD_INSTALL_DIR/

ENTRYPOINT ["java", "-jar" "/opt"]
#Default command is CalculateHsMetrics.jar
CMD ["/opt/CalculateHsMetrics.jar"]


After building the image:

docker build -t picard-1.113 .

The image runs (CalculateHsMetrics.jar by default):

docker run picard-1.113


To call other picard programs:

docker run picard-1.113 /opt/MarkDuplicates.jar

Then import to singularity:
docker run --name picard-export picard-1.113 /bin/true
singularity create
picard-1.113.img
docker
export picard-export | singularity import picard-1.113.img

This import setup works well for other docker images I'm running, but the java image doesn't work:
singularity run picard-1.113.img
ERROR  : No run driver found inside container
ABORT  : Retval = 255

singularity exec picard-1.113.img /opt/CalculateHsMetrics.jar
WARNING: Container does not have an exec helper script, calling '/opt/CalculateHsMetrics.jar' directly
ERROR  : Failed to execvp() /opt/CalculateHsMetrics.jar: Permission denied
ABORT  : Retval = 255

Can someone please point me in the right direction?

Thanks,
Sheena

vanessa s

unread,
Jul 14, 2017, 7:26:21 PM7/14/17
to singu...@lbl.gov
Hey Sheena!

I think it has to do with the way you are converting from Docker --> Singularity - I'm not actually sure what the steps do that first run the image (with picard-export /bin/true) and then import that subset into a Singularity image. My guess is that for the first line, you are only exporting a subset of content, and the image fails because it doesn't have a proper operating system. Is there any reason you wouldn't just export the entire docker image into the new singularity?

For a sanity check, I built the same image completely in Singularity - the SIngularity file looks like this:

Bootstrap: docker
From: anapsix/alpine-java:jdk7
 
%post 
 
apk update \
      &&   apk add ca-certificates wget \
      &&   update-ca-certificates
PICARD_INSTALL_DIR=/opt
version=1.113

wget http://sourceforge.net/projects/picard/files/picard-tools/${version}/picard-tools-${version}.zip && \
    unzip picard-tools-${version}.zip && \
    cp picard-tools-${version}/*jar $PICARD_INSTALL_DIR/ 
 
%environment
PICARD_INSTALL_DIR=/opt
version=1.113 
 
%runscript 
 
cd /opt
# No arguments
if [ $# -eq 0 ]
  then
      exec java -jar "$@"
  else
      exec java -jar /opt/CalculateHsMetrics.jar
fi

and then generation looks like this:

singularity create picard.img
sudo singularity bootstrap picard.img Singularity
./picard.img

(the help for the jar comes up)

So - there are a few options here:

- build the entire thing as I did above, in Singularity
- bootstrap directly from the Docker image (aka, have that Dockerfile hosted on Docker Hub or similar). Assuming your username is sheena, and the image is picard, you would do:

singularity pull docker://sheena/picard 

The last option is to try the import like you did above, but just do the entire image.

Hopefully one of those will work for you!

Best,

Vanessa
 

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.



--
Vanessa Villamia Sochat
Stanford University '16

Sheena

unread,
Jul 17, 2017, 2:40:47 PM7/17/17
to singularity
Thanks for the quick reply! Using your singularity build file works, which will have to be the solution. I tried various ways to import from the docker image (directly and from docker hub) but nothing worked except the singularity file.

Thanks again
-Sheena

vanessa s

unread,
Jul 17, 2017, 2:47:59 PM7/17/17
to singu...@lbl.gov
Awesome! Glad to help.

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.
Reply all
Reply to author
Forward
0 new messages