Skip to content

Commit 06c7592

Browse files
authored
Revise Docker documentation for clarity and structure
Updated Docker documentation to improve clarity and organization, including sections on installation, usage, and architecture support.
1 parent cbf9f61 commit 06c7592

File tree

1 file changed

+67
-67
lines changed

1 file changed

+67
-67
lines changed

docs/documentation/docker.md

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,97 @@
1-
# Docker
1+
# Containers
22

3-
## Navigating Docker Desktop/CLI
3+
## Navigating Docker
44

5-
- Install Docker on [Mac](https://docs.docker.com/desktop/setup/install/mac-install/), [Windows](https://docs.docker.com/desktop/setup/install/windows-install/), or [Linux](https://docs.docker.com/desktop/setup/install/linux/).
5+
Install Docker on
6+
* [MacOS](https://docs.docker.com/desktop/setup/install/mac-install/)
7+
* [Windows](https://docs.docker.com/desktop/setup/install/windows-install/)
8+
* [Linux](https://docs.docker.com/desktop/setup/install/linux/)
69

7-
Via Docker Desktop GUI,
8-
- Search for [sbryngelson/mfc](https://hub.docker.com/r/sbryngelson/mfc) repository where all the MFC images are stored then pull a release tag (e.g., `latest-cpu`).
10+
### Docker Desktop GUI
911

10-
Read through the **Tag Details** below to distinguish between them. Docker Desktop's left sidebar has two key tabs: **Images** stores your program copies, while **Containers** shows instances of those images. You can launch multiple containers from a single image.
12+
- Search for the [sbryngelson/mfc](https://hub.docker.com/r/sbryngelson/mfc) repository. All the MFC containers are stored here.
1113

12-
- Start a container by clicking the Run button in the Images tab.
14+
- Find and pull a release tag (e.g., `latest-cpu`).
1315

14-
Use the *Exec* section to interact with MFC directly via terminal, the *Files* section to transfer files between your device and container, and the *Stats* section to display resource usage.
16+
* Read through the **Tag Details** below to distinguish between them. Docker Desktop's left sidebar has two key tabs: **Images** stores your program copies, and **Containers** shows instances of those images. You can launch multiple containers from a single image.
1517

16-
Or via Docker CLI,
18+
- Start a container by navigating to the `Images` tab and clicking the `Run` button.
1719

18-
- Pull from [sbryngelson/mfc](https://hub.docker.com/r/sbryngelson/mfc) repository and run the latest MFC container.
20+
* Use the *Exec* section to interact with MFC directly via terminal, the *Files* section to transfer files between your device and container, and the *Stats* section to display resource usage.
1921

22+
### Docker CLI
23+
24+
You can navigate Docker entirely from the command line.
25+
From a bash-like shell, pull from the [sbryngelson/mfc](https://hub.docker.com/r/sbryngelson/mfc) repository and run the latest MFC container:
2026
```bash
2127
docker run -it --rm --entrypoint bash sbryngelson/mfc:latest-cpu
2228
```
23-
<br>
24-
25-
**Selecting OS/ARCH:**
2629

27-
Docker by default selects the compatible architecture when pulling and running a container. However, you can manually specify your platform (i.e., `linux/amd64` for most devices or `linux/arm64` for Apple Silicon).
30+
**Selecting OS/ARCH:** Docker selects the compatible architecture by default when pulling and running a container.
31+
You can manually specify your platform if something seems to go wrong, as Docker may suggest doing so.
32+
For example, `linux/amd64` handles many *nix-based x86 architectures, and `linux/arm64` handles Apple Silicon and Arm-based *nix devices.
33+
You can specify it like this:
2834
```bash
2935
docker run -it --rm --entrypoint bash --platform linux/amd64 sbryngelson/mfc:latest-cpu
3036
```
31-
<br>
32-
33-
**What is Next:**
3437

35-
After starting a container, the primary working directory is `/opt/MFC`, where all necessary files are located. Read through [Example Cases](https://mflowcode.github.io/documentation/md_examples.html) to get familiar with running cases, then review [Case Files](https://mflowcode.github.io/documentation/md_case.html) to write a custom case file.
38+
**What's Next?**
3639

40+
Once a container has started, the primary working directory is `/opt/MFC`, and all necessary files are located there.
41+
You can check out the usual MFC documentation, such as the [Example Cases](https://mflowcode.github.io/documentation/md_examples.html), to get familiar with running cases.
42+
Then, review the [Case Files](https://mflowcode.github.io/documentation/md_case.html) to write a custom case file.
3743

38-
<br>
44+
## Details on Running Containers
3945

40-
## Running Containers
41-
42-
Start a CPU container.
46+
Let's take a closer look at running MFC within a container.
47+
Kick off a CPU container:
4348
```bash
4449
docker run -it --rm --entrypoint bash sbryngelson/mfc:latest-cpu
4550
```
46-
Start a GPU container.
51+
Or, start a GPU container.
4752
```bash
4853
docker run -it --rm --gpus all --entrypoint bash sbryngelson/mfc:latest-gpu
4954
```
50-
**Note:** `--gpus all` exposes the container to available GPUs, and only NVIDIA GPUs are currently supported. Make sure your device's CUDA version is at least 12.3 to avoid backward compatibility issues.
5155

52-
<br>
53-
<br>
56+
**Note:** `--gpus all` exposes the container to available GPUs, and _only NVIDIA GPUs are currently supported_.
57+
[Ensure your device's CUDA version is at least 12.3](https://stackoverflow.com/questions/9727688/how-to-get-the-cuda-version) to avoid backward compatibility issues.
5458

55-
**Mounting Directory:**
59+
**Mounting Directory**
5660

57-
Mount a directory to `mnt` inside the container to easily transfer files between the host and the container, e.g. `cp -r <source> /mnt/destination>`.
61+
Mount a directory to `mnt` inside the container to easily transfer files between your host computer and the separate container.
62+
For example, `cp -r <source> /mnt/destination>` moves something from your source computer to the container (reverse the order for the reverse to happen!).
5863
```bash
5964
docker run -it --rm --entrypoint bash -v "$PWD":/mnt sbryngelson/mfc:latest-cpu
6065
```
61-
<br>
6266

63-
**Shared Memory:**
67+
**Shared Memory**
6468

65-
When encountering MPI memory binding errors resulting in failed tests and cases, increase the shared memory size or disable MPI inside the container (`./mfc.sh --no-mpi`).
69+
If you run a job with multiple MPI ranks, you could run into _MPI memory binding errors_.
70+
This can manifest as a failed test (launched via `./mfc.sh test`) and running cases with `./mfc.sh run -n X <path/to/case.py>` where `X > 1`.
71+
To avoid this issue, you can increase the shared memory size (to keep MPI working):
6672
```bash
6773
docker run -it --rm --entrypoint bash --shm-size=<e.g., 4gb> sbryngelson/mfc:latest-cpu
6874
```
75+
or avoid MPI altogether via `./mfc.sh <your commands> --no-mpi`.
6976

7077

78+
### Portability
7179

72-
73-
### **For Portability,**
74-
75-
On the source machine,
76-
- Pull and save the image.
80+
On the source machine, pull and save the image:
7781
```bash
7882
docker pull sbryngelson/mfc:latest-cpu
7983
docker save -o mfc:latest-cpu.tar sbryngelson/mfc:latest-cpu
8084
```
81-
On the target machine,
82-
- Load and run the image.
85+
On the target machine, load and run the image:
8386
```bash
8487
docker load -i mfc:latest-cpu.tar
8588
docker run -it --rm mfc:latest-cpu
8689
```
8790

88-
<br>
91+
## Using Supercomputers/Clusters via Apptainer/Singularity
8992

90-
## HPC Cluster Usage (Apptainer/Singularity)
93+
### Interactive Shell
9194

92-
### **Interactive Shell**
9395
```bash
9496
apptainer shell --nv --fakeroot --writable-tmpfs --bind "$PWD":/mnt docker://sbryngelson/mfc:latest-gpu
9597
Apptainer>cd /opt/MFC
@@ -98,24 +100,23 @@ or
98100
```bash
99101
apptainer exec --nv --fakeroot --writable-tmpfs --bind "$PWD":/mnt docker://sbryngelson/mfc:latest-gpu bash -c "cd /opt/MFC && bash"
100102
```
101-
**Note:** To run MFC on CPU cores, omit `--nv` and use `mfc:latest-cpu` container image.
103+
To run MFC on CPUs, omit `--nv` and use the `mfc:latest-cpu` container image.
104+
105+
### For Portability
102106

103-
### **For Portability,**
104-
On the source machine,
105-
- Pull and translate the image into `.sif` format.
107+
On the source machine, pull and translate the image into `.sif` format:
106108
```bash
107109
apptainer build mfc:latest-gpu.sif docker://sbryngelson/mfc:latest-gpu
108110
```
109-
On the target machine,
110-
- Load and start an interactive shell.
111+
On the target machine, load and start an interactive shell:
111112
```bash
112113
apptainer shell --nv --fakeroot --writable-tmpfs --bind "$PWD":/mnt mfc:latest-gpu.sif
113114
```
114115

115-
116-
117116
### Slurm Job
118-
Below is a slurm job template. Refer to your HPC user guide for instructions on properly loading and using apptainer.
117+
118+
Below is an example Slurm batch job script.
119+
Refer to your machine's user guide for instructions on properly loading and using Apptainer.
119120
```bash
120121
#!/bin/bash
121122
#SBATCH --job-name=mfc-sim
@@ -136,18 +137,16 @@ apptainer exec --nv --fakeroot --writable-tmpfs \
136137
$CONTAINER \
137138
bash -c "cd /opt/MFC && ./mfc.sh run sim/case.py -- -c <computer>"
138139
```
139-
Where,
140-
141-
`/sim` directory should all the simulation files, including the case setup (`case.py`).
142-
143-
`--nv --fakeroot --writable-tmpfs`, these flags are critical to:
144-
- Grant access to the host system's NVIDIA GPUs and its CUDA libraries.
145-
- Enable root-like permissions inside the container without actual root access.
146-
- Allow temporary write access to the container filesystem.
147-
148140

141+
In the above,
142+
* The `/sim` directory should have all the simulation files, including the case setup (`case.py`).
143+
* The `--nv --fakeroot --writable-tmpfs` set of flags are needed to
144+
- Grant access to the host system's NVIDIA GPUs and its CUDA libraries.
145+
- Enable root-like permissions inside the container without actual root access.
146+
- Allow temporary write access to the container filesystem.
149147

150148
## Tag Details
149+
151150
### Base Images
152151
- CPU images (v4.3.0-latest releases) are built on **Ubuntu 22.04**.
153152
- GPU images (v4.3.0-latest releases) are built on **NVHPC SDK 23.11 (CUDA 12.3) & Ubuntu 22.04**.
@@ -157,16 +156,21 @@ Where,
157156
- **`cpu/gpu`** - Build configurations for CPU or GPU acceleration.
158157
- **`ubuntu-xx.xx`** - Base Ubuntu version (standard = `amd64`, `-arm` = `arm64`)
159158

160-
### Available Tags
161-
```
159+
### Example Tags
160+
161+
```shell
162162
mfc:latest-xxx # Latest version (amd64 & arm64)
163163
mfc:vx.x.x-cpu # CPU version (amd64 & arm64)
164164
mfc:vx.x.x-gpu # GPU version (amd64 & arm64)
165165
mfc:vx.x.x-xxx-ubuntu-xx.xx # amd64 natively-supported version
166166
mfc:vx.x.x-xxx-ubuntu-xx.xx-arm # arm64 natively-supported version
167167
```
168-
### **Architecture Support**
169-
You can specify the desired architecture with `--platform <os>/<arch>` - either `linux/amd64` or `linux/arm64`. If unsure, Docker automatically selects the compatible image with your system architecture. If native support isn't available, QEMU emulation is enabled for the following architectures albeit with degraded performance.
168+
169+
### Architecture Support
170+
171+
You can specify your architecture with `--platform <os>/<arch>`, typically either `linux/amd64` or `linux/arm64`.
172+
If you are unsure, Docker automatically selects the compatible image with your system architecture.
173+
If native support isn't available, QEMU emulation is enabled for the following architectures, albeit with degraded performance.
170174
```
171175
linux/amd64
172176
linux/amd64/v2
@@ -182,7 +186,3 @@ linux/loong64
182186
linux/arm/v7
183187
linux/arm/v6
184188
```
185-
186-
187-
<br>
188-
<br>

0 commit comments

Comments
 (0)