3. Apptainer Bind: Sharing Data Between Host and Container¶
Apptainer's bind feature allows users to map directories from the host system into the container environment. This is essential for reading or writing data, leveraging host-based filesystems, or sharing results from container jobs.
How Binding Works¶
By default, Apptainer binds your home directory and current working directory into containers. You can also specify custom bind mounts using the --bind flag or the environment variable APPTAINER_BIND. Our recommendation is to use the latter option to bind the full BMRC file system
- Set the
APPTAINER_BINDvariable before launching the container (useful for repeated binds).
Making this bind Permanent
We recommend adding these environment variable to your ~/.bashrc file so they're automatically set for all future sessions
code
One time consumption binding:
Best Practices
-
If the destination is omitted, Apptainer mounts the directory to the same path in the container (e.g., /project → /project).
-
Paths must be absolute; relative paths are not accepted.
-
Use binds to access input/output data, reference scripts, or share results with the host system.
-
Bind mounts are a central aspect of making containers practical in HPC environments, facilitating seamless data movement between host and container