Reputation: 2349
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
--home
flag : This maps a folder on the host as the home directory, rather than a folder in the container.$HOME
environment variable with --env HOME=/opt
: I get the error Overriding HOME environment variable with SINGULARITYENV_HOME is not permitted
this question is related, but interested in mapping the container's home folder to a folder on the host machine
Upvotes: 5
Views: 1571
Reputation: 11
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
Upvotes: 1