Skip to content

Commit 65f88b8

Browse files
committed
Merge plugin development from #761
2 parents da4bbee + a196d96 commit 65f88b8

File tree

25 files changed

+2813
-8
lines changed

25 files changed

+2813
-8
lines changed
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
name: Docker Environment Setup
3+
description: Set up a Docker container for running Nextflow training examples. Handles basic setup, Docker-outside-of-Docker (DooD) for containerized processes, ARM Mac platform emulation, and troubleshooting. Use when you need to run Nextflow examples in a consistent environment.
4+
---
5+
6+
# Docker Environment Setup
7+
8+
Set up a Docker container environment for running Nextflow training examples. This skill handles all Docker configuration needed to match the Codespaces/Gitpod environment that learners use.
9+
10+
## Initial Questions
11+
12+
Use `AskUserQuestion` to determine the setup type:
13+
14+
**Which Docker setup do you need?**
15+
16+
- **Basic setup (Recommended)** - For tutorials without containerized processes (e.g., hello_nextflow basics, plugin_development)
17+
- **DooD setup** - For tutorials with containerized processes (e.g., genomics, essential_scripting_patterns)
18+
- **Check/restart existing** - Verify or restart an existing nf-training container
19+
20+
---
21+
22+
## Determine NXF_VER
23+
24+
Before any Docker commands, read the Nextflow version from devcontainer.json:
25+
26+
```bash
27+
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
28+
echo "Using NXF_VER=${NXF_VER}"
29+
```
30+
31+
This ensures you use the same version learners get in Codespaces.
32+
33+
---
34+
35+
## Basic Setup
36+
37+
For tutorials that don't use containerized processes:
38+
39+
```bash
40+
# Clean up any existing container
41+
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
42+
43+
# Start fresh container with UTF-8 locale support
44+
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
45+
docker run -d --name nf-training \
46+
-e NXF_VER=${NXF_VER} \
47+
-e LANG=C.UTF-8 \
48+
-e LC_ALL=C.UTF-8 \
49+
-v "${PWD}:/workspaces/training" \
50+
-w /workspaces/training \
51+
ghcr.io/nextflow-io/training:latest \
52+
sleep infinity
53+
```
54+
55+
**Important**: The `LANG=C.UTF-8` and `LC_ALL=C.UTF-8` environment variables are critical for handling non-ASCII characters (like "Holà", "Grüß Gott") in file names and content.
56+
57+
### Running Commands
58+
59+
```bash
60+
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 \
61+
-w /workspaces/training/<working-dir> \
62+
nf-training \
63+
<command>
64+
```
65+
66+
---
67+
68+
## Docker-outside-of-Docker (DooD) Setup
69+
70+
For tutorials with containerized processes (FASTP, BWA, SAMTOOLS, etc.):
71+
72+
```bash
73+
# Clean up any existing container
74+
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
75+
76+
# Get NXF_VER and host path
77+
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
78+
HOST_PATH="${PWD}"
79+
80+
# Start container with DooD support
81+
docker run -d --name nf-training \
82+
-e NXF_VER=${NXF_VER} \
83+
-e LANG=C.UTF-8 \
84+
-e LC_ALL=C.UTF-8 \
85+
-v /var/run/docker.sock:/var/run/docker.sock \
86+
-v "${HOST_PATH}:${HOST_PATH}" \
87+
-w "${HOST_PATH}" \
88+
ghcr.io/nextflow-io/training:latest \
89+
sleep infinity
90+
91+
# Create symlink for Codespaces paths
92+
docker exec nf-training bash -c "rm -rf /workspaces/training && mkdir -p /workspaces && ln -sf ${HOST_PATH} /workspaces/training"
93+
```
94+
95+
**Critical differences from basic setup:**
96+
97+
1. **Docker socket mount** (`-v /var/run/docker.sock:/var/run/docker.sock`) - Allows Nextflow to spawn sibling containers
98+
2. **Matching host paths** (`-v "${HOST_PATH}:${HOST_PATH}"`) - Work directories resolve correctly between containers
99+
3. **Symlink** - Makes `/workspaces/training/...` paths work locally
100+
101+
### Running Commands with DooD
102+
103+
```bash
104+
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e USER=testuser \
105+
-w "${HOST_PATH}/<working-dir>" \
106+
nf-training \
107+
nextflow run <script.nf> [options]
108+
```
109+
110+
### When DooD is Needed
111+
112+
Any tutorial where processes specify containers:
113+
114+
- `hello_nextflow` (later lessons with containers)
115+
- `nf4_science/genomics` and other domain modules
116+
- Side quests: `essential_scripting_patterns`, `metadata`, etc.
117+
118+
---
119+
120+
## Apple Silicon (ARM) Macs
121+
122+
Most bioinformatics containers are built for x86_64/amd64. On ARM Macs, create a platform config:
123+
124+
```bash
125+
docker exec nf-training bash -c 'cat > /tmp/platform.config << EOF
126+
docker.runOptions = "--platform linux/amd64"
127+
EOF'
128+
```
129+
130+
Include when running:
131+
132+
```bash
133+
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e USER=testuser \
134+
-w "${HOST_PATH}/<working-dir>" \
135+
nf-training \
136+
nextflow run <script.nf> -c /tmp/platform.config
137+
```
138+
139+
**Note**: Platform emulation uses more memory. For OOM errors (exit code 137), increase Docker Desktop memory in Preferences → Resources.
140+
141+
---
142+
143+
## Troubleshooting
144+
145+
| Error | Cause | Solution |
146+
| ---------------------------------------- | ------------------- | ---------------------------------------------------- |
147+
| `Cannot connect to Docker daemon` | Socket not mounted | Add `-v /var/run/docker.sock:/var/run/docker.sock` |
148+
| `.command.sh: No such file or directory` | Path mismatch | Use matching paths: `-v "${HOST_PATH}:${HOST_PATH}"` |
149+
| `exec format error` | ARM/x86 mismatch | Add `--platform linux/amd64` to docker.runOptions |
150+
| Exit code 137 (OOM) | Insufficient memory | Increase Docker Desktop memory allocation |
151+
| `Malformed input or unmappable chars` | Missing UTF-8 | Add `-e LANG=C.UTF-8 -e LC_ALL=C.UTF-8` |
152+
| `Error: No such container: nf-training` | Container stopped | Restart container (see below) |
153+
154+
---
155+
156+
## Container Restart Procedure
157+
158+
The container may stop during long sessions. To restart:
159+
160+
```bash
161+
# 1. Check if container is running
162+
docker ps | grep nf-training
163+
164+
# 2. If not running, restart with DooD setup
165+
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
166+
167+
HOST_PATH="${PWD}"
168+
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
169+
170+
docker run -d --name nf-training \
171+
-e NXF_VER=${NXF_VER} \
172+
-e LANG=C.UTF-8 \
173+
-e LC_ALL=C.UTF-8 \
174+
-v /var/run/docker.sock:/var/run/docker.sock \
175+
-v "${HOST_PATH}:${HOST_PATH}" \
176+
-w "${HOST_PATH}" \
177+
ghcr.io/nextflow-io/training:latest \
178+
sleep infinity
179+
180+
# 3. Recreate symlink (critical!)
181+
docker exec nf-training bash -c "rm -rf /workspaces/training && mkdir -p /workspaces && ln -sf ${HOST_PATH} /workspaces/training"
182+
183+
# 4. Recreate platform config if needed (ARM Macs)
184+
docker exec nf-training bash -c 'cat > /tmp/platform.config << EOF
185+
docker.runOptions = "--platform linux/amd64"
186+
EOF'
187+
```
188+
189+
---
190+
191+
## Cleanup
192+
193+
When done with testing:
194+
195+
```bash
196+
docker stop nf-training && docker rm nf-training
197+
```
198+
199+
---
200+
201+
## Notes
202+
203+
- Always verify you're in the repository root before starting (check for `mkdocs.yml`)
204+
- The container uses `sleep infinity` so it persists across multiple command executions
205+
- Symlink must be recreated each time the container restarts
206+
- For long sessions, periodically check container is still running: `docker ps | grep nf-training`

0 commit comments

Comments
 (0)