alex_danielssen
alex_danielssen

Reputation: 2349

Change singularity home directory to a folder within the container

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:

Other questions

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

Upvotes: 5

Views: 1571

Answers (1)

Elijah
Elijah

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

Related Questions