4

Background

I have a singularity container that was created from a docker image. The docker image has files that are meant to be in the user's home directory (e.g. in $HOME/.files). Because I don't know what the username will be, I put the files in /opt in the container and want to set the user's home to /opt.

I would like to be able to run the container with /opt as the home directory, OR somehow be able to run the container so that the home directory contains the files that already exist within the container

What I have tried:

  • use the --home flag : This maps a folder on the host as the home directory, rather than a folder in the container.
  • try overriding the $HOME environment variable with --env HOME=/opt : I get the error Overriding HOME environment variable with SINGULARITYENV_HOME is not permitted

Other questions

this question is related, but interested in mapping the container's home folder to a folder on the host machine

alex_danielssen
  • 1,839
  • 1
  • 8
  • 19

1 Answers1

1

You can use the $HOME shell environment variable when you bind the two directories.

singularity exec -B $HOME:/opt example_container.sif touch /opt/file

Here is the documentation on singularity's bind feature

Elijah
  • 11
  • 2