Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Please note that these environment variables will be cleared once you end the interactive HPC session (via exit).

Mounting host volumes

In docker, you can bind host volumes during runtime with the -v flag. In Singularity, the equivalent flag is -B:

Code Block
singularity -B /host/one:/one,/host/two/file.txt:/file.txt example.simg

This will bind the folder /host/one to /one within the container, and the file /host/two/file.txt to /file.txt within the container.

For more details, see the Singularity documentation on Bind Paths and Mounts.

Environment variables

In Docker, you can pass environment variables during runtime with the --env-file flag.

Singularity, by default, mirrors the host environment, so you can set the environment there. Alternatively, you can set environment variables by prepending them with SINGULARITYENV. In this example, we set SINGULARITYENV_HELLO, which is accessible within the container as HELLO:

Code Block
SINGULARITYENV_HELLO=world singularity exec centos7.img env | grep HELLO
> HELLO=world

If you need to clear the host environment data, use --cleanenv.

For more details, see the Singularity documentation on Environment and Metadata.