Skip to content

Commit c308580

Browse files
authored
Create 03_apptainer_files.mdx
1 parent 7932456 commit c308580

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Files in Apptainer Containers
2+
Apptainer is designed to work closely with the host filesystem. In most cases, your home directory and current working directory remain accessible from within the container.
3+
4+
## Accessing Your Files
5+
6+
While inside a container, check your current directory:
7+
8+
```bash
9+
pwd
10+
```
11+
12+
You can also list files in your home directory:
13+
14+
```bash
15+
ls ~
16+
```
17+
18+
The files and directories you see should match those available outside the container.
19+
20+
Files created in these mounted directories remain available after the container exits.
21+
22+
## Binding Additional Directories
23+
24+
Sometimes you may need access to additional directories that are not automatically available inside the container.
25+
26+
Apptainer allows additional directories to be mounted using the `-B` option:
27+
28+
```bash
29+
apptainer shell \
30+
-B /scratch:/scratch \
31+
/share/apps/images/ubuntu-24.04.3.sif
32+
```
33+
34+
This makes `/scratch` available inside the container.
35+
36+
You can also mount a directory at a different location:
37+
38+
```bash
39+
apptainer shell \
40+
-B /scratch:/data \
41+
/share/apps/images/ubuntu-24.04.3.sif
42+
```
43+
44+
In this example, files stored in `/scratch` on the host system are accessible through `/data` inside the container.
45+
46+
## Why This Matters
47+
48+
Container images are typically read-only. Research data, scripts, notebooks, and output files usually remain outside the container.
49+
50+
By making host directories available inside the container, Apptainer allows applications to access data stored on Torch while maintaining a reproducible software environment.

0 commit comments

Comments
 (0)