singularity shell exclude some directories

230 views
Skip to first unread message

Tong Qiu

unread,
May 8, 2019, 3:23:25 PM5/8/19
to singularity
Hi all,

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?


Best,
Tong

Robert Lugg

unread,
May 10, 2019, 2:00:55 PM5/10/19
to singularity
I don't believe this is possible.

Thomas Hartmann

unread,
May 13, 2019, 3:47:52 AM5/13/19
to singu...@lbl.gov
Hi Tong,

unfortunately no 'nested' bind mount seem to be possible

I.e., with a structure as
> ls /tmp/foo/
baz nope

my idea was just to bind another dir/file over one of the subdirs, e.g.,

--bind /tmp/foo:/tmp/foo --bind /dev/null:/tmp/foo/nope

but unfortunately that fails

It seems to be a general thing, as also stacking manual binds into each
other is not well received

> mount --bind /tmp/foo /tmp/bindfoo

> mount --bind /dev/null /tmp/bindfoo/nope/
mount: /tmp/bindfoo/nope: mount(2) system call failed: Not a directory.

> stat /tmp/bindfoo/nope/
File: /tmp/bindfoo/nope/
Size: 40 Blocks: 0 IO Block: 4096 directory
Device: 2ch/44d Inode: 12988919 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 1000/hartlocal) Gid: ( 1000/hartlocal)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-05-13 09:46:57.473719869 +0200
Modify: 2019-05-13 09:37:20.746773623 +0200
Change: 2019-05-13 09:37:20.746773623 +0200
Birth: -


Cheers,
Thomas
> --
> You received this message because you are subscribed to the Google
> Groups "singularity" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to singularity...@lbl.gov
> <mailto:singularity...@lbl.gov>.

David Godlove

unread,
May 13, 2019, 5:41:24 PM5/13/19
to singularity
I think you could do this creatively by only binding the exact directories and files you need.  The argument to the --bind option can be a very long comma separated list if you want it to be.  

To unsubscribe from this group and stop receiving emails from it, send an email to singularity...@lbl.gov.
To view this discussion on the web visit https://groups.google.com/a/lbl.gov/d/msgid/singularity/331bb94b-a0db-1cf5-2a9a-0a5603db1158%40desy.de.

David Godlove

unread,
May 13, 2019, 5:49:51 PM5/13/19
to singularity
For instance:

vagrant@vagrant:~$ tree /data
/data
├── bindme
│   └── foo
├── dontbindme
│   └── bar
├── that
└── this

2 directories, 4 files
vagrant@vagrant:~$ singularity exec --bind /data/bindme,/data/this,/data/that my-container.sif tree /data
/data
|-- bindme
|   `-- foo
|-- that
`-- this
Reply all
Reply to author
Forward
0 new messages