How to redirect output in SIngularity container

1,298 views
Skip to first unread message

Sam

unread,
Jan 16, 2018, 5:52:40 PM1/16/18
to singularity
Hell all,

I'm very new to Singularity and i built and ran my first HPC application in a container. Now i need to save the output somewhere. I just did :

%runscript
./binary  | tee $SINGULARITY_ROOTFS/tempdir/resultsfile
or
./binary > $SINGULARITY_ROOTFS/tempdir/resultsfile

But im getting a permission error 

How and where can i save the output of a container run?

Thank you,

v

unread,
Jan 16, 2018, 6:01:56 PM1/16/18
to singu...@lbl.gov
Hey Sam!

The runscript is what gets executed after the container is built, so the environment variable `$SINGULARITY_ROOTFS` is long gone (it's only relevant in a build specification file in the %setup section at build time). So if you want to write an output file, if you direct it somewhere in the container you will get an error (the container is read only!) Instead, try binding a directory that you have write access for to the container, eg:

singularity run --bind /path/with/write:/opt container.simg

and then in the runscript, make sure to write your result to whatever that directory is (in the above example, /opt)

%runscript
./binary  | tee /opt/resultsfile

Most default installations will bind /tmp automatically where you would have write, so you could also skip the bind and write there. If you want more specific details or help, please share your recipe and the output that you are getting, and we can go from there!

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

Rémy Dernat

unread,
Jan 17, 2018, 3:21:24 AM1/17/18
to singu...@lbl.gov
Hi,

FYI, you can pipe the output of a command to a singularity container : http://singularity.lbl.gov/user-guide#compatibility-with-standard-work-flows-pipes-and-io

I would not store the results in a container, but rather in a bind directory.

Best regards,
Rémy

To unsubscribe from this group and stop receiving emails from it, send an email to singularity...@lbl.gov.



--
Vanessa Villamia Sochat
Stanford University '16

Tyler Trafford

unread,
Jan 17, 2018, 10:02:21 AM1/17/18
to singu...@lbl.gov
I would recommend leaving the redirect out of the runscript.  Just let it go to stdout and redirect that output when you run the container image.

-Tyler

--
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.



--
Tyler Trafford

Sam

unread,
Jan 17, 2018, 12:35:31 PM1/17/18
to singularity
Every suggestion here worked. THank you all.
Reply all
Reply to author
Forward
0 new messages