Introduction/Overview
This lesson and the subsequent practice, focus on bind mounts. Bind mounts are extremely important for working with neuroimaging containers. One often requires several separate bind mounts for separate directories, in addition to a clear understanding of the inside vs the outside as defined by those mounts.
Understanding Bind Mounts
- Docker containers are isolated from your computer, which makes it difficult for them to process data ON your computer!
- A bind mount solves this problem by providing Docker access to a directory on your computer (i.e., the "outside") as if it were inside the container.
- The
-v
bind mount flag is quite common. After the-v
flag, you must specify the bind using the correct order:outside:inside
. - outside = the absolute path to the directory on your computer.
"${PWD}"
can be that absolute path if you run the Docker command from the directory you want to mount.
- inside = the absolute path to some mount point inside the container.
- Because it is an absolute path, the path must start with
/
. - For BIDS, the inside mount points are usually something like
/data
and/out
. - Try to stick to the examples provided with the BIDS app (but, if you make up a name for the inside mount, that usually works fine with the
-v
flag).
- Because it is an absolute path, the path must start with
Example
- In this example, the BIDS container has two bind mounts indicated by
-v
flags:
- QSIprep requires 5 bind mounts for the reconstruction!
Read-Only
- You can optionally specify that the mounted directory is read-only
:ro
: This is suggested for the BIDS data directory in most cases. - An exception to mounting the BIDS data directory read-only: If you are defacing the structural image, then you must create and remove files from the BIDS data directory. In this case, it can't be read-only.
- Download the Docker-Singularity_Rosetta_Stone.pdf to compare Docker and Singularity commands: The Rosetta stone focuses on bind mounts. Generally, Docker is much pickier about bind mounts than Singularity, but a mount that works for Docker should work for Singularity.
Bind mounts Illustrated
- In the ~5-minute video below, the container and the internal mount points are in red.
- The container is running on a computer. The computer and its mount points are in blue.
- The arrows illustrate how the external mount points are bound to each of the internal mount points:
-v external_mount:internal_mount
Bind mounts: A Deeper Dive
In this 21-minute video, Tom Hicks explains bind mounts in more detail.
Digest
Summary
This lesson focused on understanding bind mounts. Bind mounts are absolutely crucial to running BIDS apps. Conceptually, you must understand relative vs absolute paths and the isolation of the container to specify bind mounts correctly.
Stop and think about these concepts and terms
absolute path
inside vs outside the container
read-only