0

singularity -B is used to mount some directories so that those directories can be used inside the singularity container. However, there are some directories that I would like to exclude. For example, I would like to use singularity shell -B /foo/ bar.simg to have access to /foo

But I would like to exclude /foo/foo1/ in the container. Is there any way to work around this?

Tong Qiu
  • 123
  • 2
  • 10

2 Answers2

1

Nope. The container isn't showing a copy or a link to files, it is making that directory (and all its contents) available inside the container. It's the same when mounting directories in docker.

tsnowlan
  • 3,472
  • 10
  • 15
0

Possible workaround: mount an empty dummy directory in place of the one you want to exclude.

Example: my home ~ is mounted, but I want to exclude ~/tmp specifically.

mkdir -p ~/tmp_container
singularity_mount=~/tmp_container:~/tmp
singularity shell -B "$singularity_mount" myimage.sif

The empty directory on the host is mounted at the location of the unwanted directory, masking the content but not the existence of the unwanted directory.

Also works for a file, if I can allow the container to instead see an empty file.