返回技能列表

setup-docker-compose

pjt222
更新于 Yesterday
2 次查看
17
2
17
在 GitHub 上查看
文档aiapimcpdata

关于

This skill configures Docker Compose for multi-container R development environments, handling service definitions, volumes, networking, and environment variables. Use it when running R alongside services like databases or APIs, or to create reproducible development setups. It helps orchestrate containers and manage configurations across development and production.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-docker-compose

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Set Up Docker Compose

Configure Docker Compose for R dev + deployment envs.

When Use

  • Running R alongside other services (databases, APIs)
  • Setting up reproducible dev env
  • Orchestrating R-based MCP server container
  • Managing env vars + volume mounts

Inputs

  • Required: Dockerfile for R service
  • Required: Project dir to mount
  • Optional: Additional services (database, cache, web server)
  • Optional: Env var config

Steps

Step 1: Create docker-compose.yml

version: '3.8'

services:
  r-dev:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: r-dev
    image: r-dev:latest

    volumes:
      - .:/workspace
      - renv-cache:/workspace/renv/cache

    stdin_open: true
    tty: true

    environment:
      - TERM=xterm-256color
      - R_LIBS_USER=/workspace/renv/library
      - RENV_PATHS_CACHE=/workspace/renv/cache

    command: R

    restart: unless-stopped

volumes:
  renv-cache:
    driver: local

Got: docker-compose.yml file exists with R service defined, volume mounts for project + renv cache, env vars for R library paths.

If fail: YAML syntax invalid? Validate with docker compose config. Indentation must use spaces (not tabs), all string values with special chars quoted.

Step 2: Add Additional Services (If Needed)

services:
  r-dev:
    # ... as above
    depends_on:
      - postgres
    environment:
      - DB_HOST=postgres
      - DB_PORT=5432

  postgres:
    image: postgres:16
    container_name: r-postgres
    environment:
      POSTGRES_DB: analysis
      POSTGRES_USER: ruser
      POSTGRES_PASSWORD_FILE: /run/secrets/db_password
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"

volumes:
  renv-cache:
  pgdata:

Got: Additional service (e.g., PostgreSQL) defined with own volume, env vars, port mapping. R service has depends_on referencing new service.

If fail: Database service fails to start? Check docker compose logs postgres for init errors. Verify env vars like POSTGRES_PASSWORD_FILE point to valid secrets or switch to POSTGRES_PASSWORD for dev.

Step 3: Configure Networking

For services needing localhost access (MCP servers).

services:
  r-dev:
    network_mode: "host"

For isolated networking.

services:
  r-dev:
    networks:
      - app-network
    ports:
      - "3000:3000"

networks:
  app-network:
    driver: bridge

Got: Networking configured: host mode for services needing localhost (MCP servers), or bridge with explicit port mappings for isolated services.

If fail: Services cannot communicate? Verify same network. With bridge, use service names as hostnames (postgres not localhost). With host mode, use localhost, ensure ports do not conflict.

Step 4: Manage Environment Variables

Make .env file (git-ignored).

R_VERSION=4.5.0
GITHUB_PAT=your_token_here

Reference in compose.

services:
  r-dev:
    build:
      args:
        R_VERSION: ${R_VERSION}
    env_file:
      - .env

Got: .env file exists (git-ignored) with project-specific variables, docker-compose.yml references via env_file or variable interpolation (${VAR}).

If fail: Variables not resolving? Ensure .env in same dir as docker-compose.yml. Run docker compose config to see resolved config with all vars expanded.

Step 5: Build and Run

# Build images
docker compose build

# Start services
docker compose up -d

# Attach to R session
docker compose exec r-dev R

# View logs
docker compose logs -f r-dev

# Stop services
docker compose down

Got: All services start. R session accessible.

If fail: Check docker compose logs for startup errors. Common: port conflicts, missing env vars.

Step 6: Create Override for Development

Make docker-compose.override.yml for local dev settings.

services:
  r-dev:
    volumes:
      - /path/to/local/packages:/extra-packages
    environment:
      - DEBUG=true

Auto merged with docker-compose.yml.

Got: docker-compose.override.yml exists with dev-specific settings (extra volumes, debug flags), auto applied when running docker compose up.

If fail: Overrides not taking effect? Verify filename exactly docker-compose.override.yml. Run docker compose config to confirm merge. For explicit override files, use docker compose -f docker-compose.yml -f custom-override.yml up.

Checks

  • docker compose build completes without errors
  • docker compose up starts all services
  • Volume mounts share files between host + container
  • Env vars available inside containers
  • Services can communicate with each other
  • docker compose down cleanly stops everything

Pitfalls

  • Volume mount permissions: Linux containers may create files as root. Use user: directive or fix permissions.
  • Port conflicts: Check for services already using same ports on host
  • Docker Desktop vs CLI: docker compose (v2) vs docker-compose (v1). Use v2.
  • WSL path mounts: Use /mnt/c/... paths when mounting Windows dirs from WSL
  • Named volumes vs bind mounts: Named volumes persist across rebuilds; bind mounts reflect host changes immediately

See Also

  • create-r-dockerfile - create Dockerfile compose references
  • containerize-mcp-server - compose config for MCP servers
  • optimize-docker-build-cache - speed up compose builds

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman/skills/setup-docker-compose
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

railway-docs

文档

Railway Docs Skill可实时获取最新的Railway官方文档,确保回答的准确性。当开发者询问Railway功能特性、工作原理或分享docs.railway.com链接时,应优先使用此技能。它通过专门的LLM优化文档源提供最新信息,避免依赖过时记忆来回答技术问题。

查看技能

n8n-code-python

文档

该Skill为在n8n平台的Python代码节点中编写代码提供专家指导,特别适用于需要使用_input/_json/_node语法、Python标准库或了解n8n中Python限制的场景。它强调JavaScript应作为首选方案,仅当需要特定Python功能或对Python语法更熟悉时才使用Python。Skill提供了快速入门模板和关键注意事项,帮助开发者在n8n中高效编写Python代码。

查看技能

archon

文档

Archon Skill为开发者提供了基于RAG的语义搜索和项目任务管理功能,可通过REST API访问知识库。它支持文档搜索、网站爬取、文件上传和版本控制,适用于技术文档查询和项目管理场景。首次使用时需要配置Archon主机地址,建议在处理外部文档时优先使用该Skill。

查看技能

n8n-code-javascript

文档

这个Skill为n8n工作流中的JavaScript代码节点提供专业指导,涵盖数据处理、HTTP请求和日期操作等核心场景。它详细解释了如何正确使用n8n特有的`$input`/`$json`语法、`$helpers`工具以及DateTime对象,并包含关键的错误排查和模式选择建议。开发者通过该Skill能快速掌握Code节点的正确返回格式、数据访问方法和常见陷阱解决方案。

查看技能