Skill站外收录 @skilllib/skill-2117939930272413919
docker-setup
为 Nextflow 培训示例提供统一的 Docker 运行环境,支持基础容器启动、Docker-in-Docker 容器化流程执行、ARM Mac 平台兼容性适配及常见故障修复,确保本地环境与 Codespaces/Gitpod 保持一致。
开发运维 AI 技能
Skills.MD
# Docker Environment Setup
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.
## Initial Questions
Use `AskUserQuestion` to determine the setup type:
**Which Docker setup do you need?**
- **Basic setup (Recommended)** - For tutorials without containerized processes (e.g., hello_nextflow basics, plugin_development)
- **DooD setup** - For tutorials with containerized processes (e.g., genomics, essential_scripting_patterns)
- **Check/restart existing** - Verify or restart an existing nf-training container
---
## Determine NXF_VER
Before any Docker commands, read the Nextflow version from devcontainer.json:
```bash
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
echo "Using NXF_VER=${NXF_VER}"
```
This ensures you use the same version learners get in Codespaces.
---
## Basic Setup
For tutorials that don't use containerized processes:
```bash
# Clean up any existing container
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
# Start fresh container with UTF-8 locale support
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
docker run -d --name nf-training \
-e NXF_VER=${NXF_VER} \
-e LANG=C.UTF-8 \
-e LC_ALL=C.UTF-8 \
-v "${PWD}:/workspaces/training" \
-w /workspaces/training \
ghcr.io/nextflow-io/training:latest \
sleep infinity
```
**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.
### Running Commands
```bash
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 \
-w /workspaces/training/<working-dir> \
nf-training \
<command>
```
---
## Docker-outside-of-Docker (DooD) Setup
For tutorials with containerized processes (FASTP, BWA, SAMTOOLS, etc.):
```bash
# Clean up any existing container
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
# Get NXF_VER and host path
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
HOST_PATH="${PWD}"
# Start container with DooD support
docker run -d --name nf-training \
-e NXF_VER=${NXF_VER} \
-e LANG=C.UTF-8 \
-e LC_ALL=C.UTF-8 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "${HOST_PATH}:${HOST_PATH}" \
-w "${HOST_PATH}" \
ghcr.io/nextflow-io/training:latest \
sleep infinity
# Create symlink for Codespaces paths
docker exec nf-training bash -c "rm -rf /workspaces/training && mkdir -p /workspaces && ln -sf ${HOST_PATH} /workspaces/training"
```
**Critical differences from basic setup:**
1. **Docker socket mount** (`-v /var/run/docker.sock:/var/run/docker.sock`) - Allows Nextflow to spawn sibling containers
2. **Matching host paths** (`-v "${HOST_PATH}:${HOST_PATH}"`) - Work directories resolve correctly between containers
3. **Symlink** - Makes `/workspaces/training/...` paths work locally
### Running Commands with DooD
```bash
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e USER=testuser \
-w "${HOST_PATH}/<working-dir>" \
nf-training \
nextflow run <script.nf> [options]
```
### When DooD is Needed
Any tutorial where processes specify containers:
- `hello_nextflow` (later lessons with containers)
- `nf4_science/genomics` and other domain modules
- Side quests: `essential_scripting_patterns`, `metadata`, etc.
---
## Apple Silicon (ARM) Macs
Most bioinformatics containers are built for x86_64/amd64. On ARM Macs, create a platform config:
```bash
docker exec nf-training bash -c 'cat > /tmp/platform.config << EOF
docker.runOptions = "--platform linux/amd64"
EOF'
```
Include when running:
```bash
docker exec -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e USER=testuser \
-w "${HOST_PATH}/<working-dir>" \
nf-training \
nextflow run <script.nf> -c /tmp/platform.config
```
**Note**: Platform emulation uses more memory. For OOM errors (exit code 137), increase Docker Desktop memory in Preferences → Resources.
---
## Troubleshooting
| Error | Cause | Solution |
| ---------------------------------------- | ------------------- | ---------------------------------------------------- |
| `Cannot connect to Docker daemon` | Socket not mounted | Add `-v /var/run/docker.sock:/var/run/docker.sock` |
| `.command.sh: No such file or directory` | Path mismatch | Use matching paths: `-v "${HOST_PATH}:${HOST_PATH}"` |
| `exec format error` | ARM/x86 mismatch | Add `--platform linux/amd64` to docker.runOptions |
| Exit code 137 (OOM) | Insufficient memory | Increase Docker Desktop memory allocation |
| `Malformed input or unmappable chars` | Missing UTF-8 | Add `-e LANG=C.UTF-8 -e LC_ALL=C.UTF-8` |
| `Error: No such container: nf-training` | Container stopped | Restart container (see below) |
---
## Container Restart Procedure
The container may stop during long sessions. To restart:
```bash
# 1. Check if container is running
docker ps | grep nf-training
# 2. If not running, restart with DooD setup
docker stop nf-training 2>/dev/null; docker rm nf-training 2>/dev/null
HOST_PATH="${PWD}"
NXF_VER=$(grep -o '"NXF_VER":\s*"[^"]*"' .devcontainer/devcontainer.json | cut -d'"' -f4)
docker run -d --name nf-training \
-e NXF_VER=${NXF_VER} \
-e LANG=C.UTF-8 \
-e LC_ALL=C.UTF-8 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "${HOST_PATH}:${HOST_PATH}" \
-w "${HOST_PATH}" \
ghcr.io/nextflow-io/training:latest \
sleep infinity
# 3. Recreate symlink (critical!)
docker exec nf-training bash -c "rm -rf /workspaces/training && mkdir -p /workspaces && ln -sf ${HOST_PATH} /workspaces/training"
# 4. Recreate platform config if needed (ARM Macs)
docker exec nf-training bash -c 'cat > /tmp/platform.config << EOF
docker.runOptions = "--platform linux/amd64"
EOF'
```
---
## Cleanup
When done with testing:
```bash
docker stop nf-training && docker rm nf-training
```
---
## Notes
- Always verify you're in the repository root before starting (check for `mkdocs.yml`)
- The container uses `sleep infinity` so it persists across multiple command executions
- Symlink must be recreated each time the container restarts
- For long sessions, periodically check container is still running: `docker ps | grep nf-training`
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「docker-setup」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次