Source profileQuality 91/100Review permissions

event4u-app/agent-config/src/skills/docker/SKILL.md

docker

Use when working with Docker — Dockerfile edits, docker-compose services, containers, or the dual-container (fast + Xdebug) setup — even when the user just says 'my container won't start'.

Source repository stars
7
Declared platforms
0
Static risk flags
3
Last source update
2026-07-28
Source checked
2026-07-28

Decision brief

What it does—and where it fits

Use when working with Docker — Dockerfile edits, docker-compose services, containers, or the dual-container (fast + Xdebug) setup — even when the user just says 'my container won't start'.

Best for

  • Production deployment (use aws-infrastructure skill)
  • Codespaces setup (use devcontainer skill)

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/event4u-app/agent-config --skill "src/skills/docker"
Safe inspection promptEditorial

Inspect the Agent Skill "docker" from https://github.com/event4u-app/agent-config/blob/0adf49a8ae84b0ff6e2de8759eea43257e020eff/src/skills/docker/SKILL.md at commit 0adf49a8ae84b0ff6e2de8759eea43257e020eff. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Procedure: Modify Docker setup

    1. Gather context — read project Docker docs in agents/ or Docs/, check Makefile/Taskfile.yml for targets, read docker-compose.yml/compose.yaml for service layout. 2. Identify scope — determine which service(s) are affected (PHP, NGINX, worker, scheduler, database). 3. Inspect c…

    Gather context — read project Docker docs in agents/ or Docs/, check Makefile/Taskfile.yml for targets, read docker-compose.yml/compose.yaml for service layout.Identify scope — determine which service(s) are affected (PHP, NGINX, worker, scheduler, database).Inspect current state — run docker compose ps to see running containers and their health status.
  2. 02

    When to use

    Use this skill when working with Docker configuration, container setup, Dockerfile changes, or docker-compose modifications.

    Production deployment (use aws-infrastructure skill)Codespaces setup (use devcontainer skill)Use this skill when working with Docker configuration, container setup, Dockerfile changes, or docker-compose modifications.
  3. 03

    Project architecture

    Multi-stage build with these targets:

    PHPVERSION — extracted from Dockerfile, used by CICOMPOSERAUTH — private registry access (passed as secret)CACHEBUST — weekly cache invalidation (date +%Y-%U)
  4. 04

    Dockerfile (.docker/Dockerfile)

    Multi-stage build with these targets:

    PHPVERSION — extracted from Dockerfile, used by CICOMPOSERAUTH — private registry access (passed as secret)CACHEBUST — weekly cache invalidation (date +%Y-%U)
  5. 05

    Dual-container architecture (PHP projects)

    Some projects run two PHP-FPM containers simultaneously (fast + Xdebug):

    No header → fast containerX-Xdebug-Enable: 1 or X-Debug-Session: PHPSTORM → Xdebug containerSome projects run two PHP-FPM containers simultaneously (fast + Xdebug):

Permission review

Static risk signals and limitations

Writes files

medium · line 17

The documentation asks the agent to create, modify, or delete local files.

**Make the change** — edit the relevant file (Dockerfile, compose file, NGINX config, Makefile target). Follow the conventions in the reference sections below.

Runs scripts

medium · line 98

The documentation asks the agent to run terminal commands or scripts.

make start # Start all containers

Runs scripts

medium · line 99

The documentation asks the agent to run terminal commands or scripts.

make stop # Stop all containers

Network access

medium · line 162

The documentation includes network, browsing, or remote request actions.

CMD curl -f http://localhost:8080/health || exit 1

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score91/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars7SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
event4u-app/agent-config
Skill path
src/skills/docker/SKILL.md
Commit
0adf49a8ae84b0ff6e2de8759eea43257e020eff
License
MIT
Collected
2026-07-28
Default branch
main
View the original SKILL.md

docker

When to use

Use this skill when working with Docker configuration, container setup, Dockerfile changes, or docker-compose modifications.

Do NOT use when:

  • Production deployment (use aws-infrastructure skill)
  • Codespaces setup (use devcontainer skill)

Procedure: Modify Docker setup

  1. Gather context — read project Docker docs in agents/ or Docs/, check Makefile/Taskfile.yml for targets, read docker-compose.yml/compose.yaml for service layout.
  2. Identify scope — determine which service(s) are affected (PHP, NGINX, worker, scheduler, database).
  3. Inspect current state — run docker compose ps to see running containers and their health status.
  4. Make the change — edit the relevant file (Dockerfile, compose file, NGINX config, Makefile target). Follow the conventions in the reference sections below.
  5. Rebuild affected containersdocker compose build <service> (add --no-cache if Dockerfile base layers changed).
  6. Verifydocker compose up -d, check docker compose ps for healthy status, run a smoke test (e.g., make test-quick or curl localhost).

Project architecture

Dockerfile (.docker/Dockerfile)

Multi-stage build with these targets:

StagePurpose
baseAlpine + PHP-FPM + system packages + extensions
devDevelopment: Xdebug, dev tools, Composer dev deps
proProduction: optimized, no dev deps, New Relic agent

Key build args:

  • PHP_VERSION — extracted from Dockerfile, used by CI
  • COMPOSER_AUTH — private registry access (passed as secret)
  • CACHEBUST — weekly cache invalidation (date +%Y-%U)
  • COMPOSER_NO_DEV1 for production, 0 for dev

Dual-container architecture (PHP projects)

Some projects run two PHP-FPM containers simultaneously (fast + Xdebug):

ContainerPurposePHP-FPM mode
{project}-phpFast execution, no debuggerpm = dynamic
{project}-php-xdebugXdebug enabled, debuggingpm = ondemand

NGINX routes requests based on HTTP headers:

  • No header → fast container
  • X-Xdebug-Enable: 1 or X-Debug-Session: PHPSTORM → Xdebug container

docker-compose services

Read docker-compose.yml / compose.yaml to discover the actual service names. Common patterns:

Service typeDescription
PHP-FPMMain application server
PHP-FPM + XdebugDebugging container
NGINXReverse proxy
Queue workerBackground job processing (e.g., Horizon)
SchedulerCron/task scheduler
DatabaseMariaDB / MySQL / PostgreSQL
CacheRedis / Memcached

Conventions

Container commands

  • Always execute PHP commands inside the container, never on the host.
  • Use docker compose exec -T <service> ... for non-interactive (scripts, CI).
  • Use make console for interactive shell access.
  • Use make console-xdebug for Xdebug container access.

Image building

  • Production images use target: pro — no dev dependencies.
  • Check the project's CI/CD config for target platform and registry.
  • Docker Hub login may be needed for pulling base images (rate limits).

PHP extensions

Extensions are installed via mlocati/php-extension-installer:

  • Check the Dockerfile for the current list.
  • Add new extensions in the base stage so they're available in all targets.

Environment files

  • .env is NOT baked into the Docker image.
  • Production: .env is fetched from AWS Secrets Manager at deploy time.
  • Development: .env is mounted via docker-compose volumes.

Makefile targets

Always check the Makefile for available targets before using raw docker commands:

make start              # Start all containers
make stop               # Stop all containers
make console            # Enter PHP container (bash)
make console-xdebug     # Enter Xdebug PHP container
make composer-install   # Run composer install in container
make migrate            # Run migrations
make migrate-and-seed   # Run migrations + seed
make test               # Run all tests (parallel)

Container orchestration

Environment synchronization

When the development environment is out of sync (missing containers, wrong state):

  1. Check statusdocker compose ps to see which services are running.
  2. Start missing servicesmake start or docker compose up -d.
  3. Rebuild if neededdocker compose build --no-cache <service> after Dockerfile changes.
  4. Reset statemake migrate-and-seed after fresh container start.

Common sync issues

SymptomCauseFix
"Connection refused"Container not runningmake start
"Table not found"Migrations not runmake migrate-and-seed
"Class not found"Composer not installedmake composer-install
Old PHP versionImage not rebuiltdocker compose build <php-service>
Extension missingDockerfile changedRebuild with --no-cache

Multi-project orchestration

When running multiple projects simultaneously:

  • Check for port conflicts — each project needs unique exposed ports.
  • Use Traefik (see traefik skill) for routing by domain instead of port.
  • Shared services (MariaDB, Redis) can be in a dedicated docker-compose.shared.yml.

Security hardening checklist

When creating or reviewing Dockerfiles:

  • Non-root user — create user with specific UID/GID, use USER directive before CMD.
  • No secrets in layers — never ENV or COPY secrets. Use --mount=type=secret (BuildKit) or runtime secrets.
  • Minimal packages — only install what's needed. Remove package manager cache in the same RUN layer.
  • Read-only root filesystem — use --read-only flag where possible, mount writable dirs explicitly.
  • No latest tag — pin base image versions (node:18.19-alpine, not node:latest).
  • Scan images — use docker scout quickview or Trivy for vulnerability scanning.
# Security pattern
RUN addgroup -g 1001 -S appgroup && \
    adduser -S appuser -u 1001 -G appgroup
COPY --chown=appuser:appgroup . .
USER 1001

Health check patterns

Always add health checks to long-running services:

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:8080/health || exit 1

In docker-compose, use condition: service_healthy for dependency ordering:

services:
  app:
    depends_on:
      db:
        condition: service_healthy

Image size optimization

TechniqueImpactWhen
Multi-stage buildsHighAlways — separate build from runtime
Alpine base imagesHighWhen compatibility allows
Distroless imagesHighProduction, no shell needed
.dockerignoreMediumAlways — exclude node_modules, .git, tests, docs
Combine RUN layersMediumWhen installing packages + cleaning cache
Copy only artifactsMediumCOPY --from=build only what's needed

Build cache optimization

Use BuildKit cache mounts for package managers:

# Composer (PHP)
RUN --mount=type=cache,target=/root/.composer/cache \
    composer install --no-dev --optimize-autoloader

# npm (Node.js)
RUN --mount=type=cache,target=/root/.npm \
    npm ci --only=production

Layer ordering for cache efficiency:

  1. System packages (changes rarely)
  2. Dependency files (composer.json, package.json) — changes sometimes
  3. RUN install — cached if dependency files unchanged
  4. Source code (COPY . .) — changes often, last layer

Output format

  1. Modified Docker configuration files (Dockerfile, docker-compose.yml)
  2. Updated Makefile targets if applicable
  3. Rebuild/restart instructions for affected containers

Auto-trigger keywords

  • Docker
  • docker-compose
  • container
  • Dockerfile
  • PHP container

Known pitfalls

SymptomRoot causeFix
Every build reinstalls all dependencies (builds are slow)COPY . . runs before the dependency install, so any source edit busts the dependency layer's cacheCopy only the manifest + lockfile (composer.json+composer.lock / package.json+lock), install deps, THEN COPY . .
Image is much larger / slower to push than expectedNo .dockerignore, so .git, vendor/, node_modules/, and local env files enter the build context and imageAdd a .dockerignore excluding VCS, installed deps, build output, and secrets
vendor/ or node_modules/ is empty inside the container even though install ranA bind-mount of the project directory shadows the image's installed-deps directoryPut a named/anonymous volume over the deps dir, or don't bind-mount over it
Files the container writes are owned by root on the hostThe container process runs as UID 0; bind-mounted writes inherit that ownerRun as a non-root USER whose UID matches the host user, or chown on entry
Container exits immediately with code 0The CMD process daemonizes/backgrounds, so PID 1 has nothing to keep aliveRun the long-lived process in the foreground as PID 1 (no &, no daemonize flag)

Gotcha

  • All PHP commands (artisan, composer, phpunit) must run INSIDE the PHP container — never on the host.
  • The fast container and Xdebug container share the same codebase but have different PHP configs — don't confuse them.
  • docker compose down -v destroys volumes including the database — use down without -v unless you mean it.
  • The model forgets to use docker compose exec -T (no TTY) when running in scripts or CI.

Do NOT

  • Do NOT change the base Alpine or PHP version without checking CI compatibility.
  • Do NOT add dev-only tools to the pro stage.
  • Do NOT hardcode secrets in the Dockerfile — use build args or runtime secrets.
  • Do NOT change platform without verifying AWS runner architecture.

Related

  • Skill: traefik — local reverse proxy with real domains and HTTPS
  • Skill: devcontainer — DevContainer and Codespaces setup
  • Skill: php-debugging — Xdebug dual-container architecture
  • Rule: docker-commands.md — all PHP commands run inside Docker

Alternatives

Compare before choosing