Skip to content
Back to skills

Docker

ASecurity

Docker and Docker Compose rules: compose.yml at the repository root, a folder under .docker/ with a Dockerfile for every service, services named after the software they run, local and prod stages and Compose files, Compose project names, env_file, local port choice, conflicts between worktrees, pinned image versions, RustFS as the local stand-in for AWS S3, and removing resources after merge. Load when working with Dockerfiles, Compose, or containers.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
developmentrustphpdockerawsgitapi

Works with

  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add the-up/ai --skill docker --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/the-up-docker/badge)](https://www.skillsdirectory.com/skills/the-up-docker)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker
description: "Docker and Docker Compose rules: compose.yml at the repository root, a folder under .docker/ with a Dockerfile for every service, services named after the software they run, local and prod stages and Compose files, Compose project names, env_file, local port choice, conflicts between worktrees, pinned image versions, RustFS as the local stand-in for AWS S3, and removing resources after merge. Load when working with Dockerfiles, Compose, or containers."
---

# Docker

- Use Docker when it's needed, especially for local development services. For a PHP project, recommend Lerd first and keep Docker as the second way, as the [Local Environment](../local-environment/SKILL.md) rules describe.
- Keep the Compose file at the repository root as `compose.yml`, so that `docker compose` works there without `-f`. Give every service a folder under `.docker/` with the service's name, holding its `Dockerfile` and its configuration files, and build the service from that Dockerfile, even when the Dockerfile only starts from the pinned upstream image (for example `FROM mariadb:10.11.19`). Reference an image with `image:` only when another repository builds and publishes it.

  ```text
  compose.yml
  .dockerignore
  .docker/
    php/
      Dockerfile
      php.ini
    caddy/
      Dockerfile
      Caddyfile
    mariadb/
      Dockerfile
      my.cnf
  ```

- Build every service with the repository root as the build context, so that the image can copy both the application files and the files in its service folder:

  ```yaml
  services:
    php:
      build:
        context: .
        dockerfile: .docker/php/Dockerfile
    mariadb:
      build:
        context: .
        dockerfile: .docker/mariadb/Dockerfile
  ```

- If there's no prod Docker setup, create only what local development needs. If there is one, build the local and prod images from stages of the same Dockerfile (for example `local` and `prod`) selected with `target`, instead of a Dockerfile per environment. If prod also runs with Compose, split the Compose files the way Docker merges them: `compose.yml` for what local and prod share, `compose.override.yml` for the local settings, which `docker compose` adds automatically, and `compose.prod.yml` for the prod settings, applied with `docker compose -f compose.yml -f compose.prod.yml`.
- Don't set the Compose project name with the top-level `name` or `COMPOSE_PROJECT_NAME`. Compose derives it in lowercase from the name of the folder that contains `compose.yml`, so each worktree gets its own project (for example `<repo>-<task-key>`). With a fixed name, all worktrees of the repository share one Compose project, and the second worktree recreates the first one's containers without a port error.
- Don't set `container_name`. Name each service after the software it runs, the same as its folder under `.docker/` (for example `php`, `caddy`, `mariadb`, `redis`), not with a generic or invented name such as `app`, `web`, or `db`. When several services run the same software, for example several applications on the same PHP image, name each after its application. Name the service's volumes and env files after it too (for example `mariadb-data`).
- Don't define application configuration and secrets with Compose `environment` or Dockerfile `ENV`/`ARG`; provide them from the existing `.env` with `env_file`. If a secret is needed at build time, use a BuildKit secret mount.
- Use `restart: "no"` for every service locally.
- Choose local host ports from the 10000–32767 range, using values that nothing on the machine listens on and that no other project in the root folder defines; unless it's needed, bind only to `127.0.0.1`. Leave container ports at their defaults.
- Start, stop, and remove only your own worktree's Compose project; don't stop or delete the containers, volumes, and networks of other worktrees and projects without approval.
- Worktrees of the same repository use the same host ports. If a port is taken, tell the user which project or process uses it; if the user approves, stop it (a Compose project with `docker compose -p <project> stop`), then start your own project.
- During post-merge cleanup, before removing the task worktree, remove the Compose project together with its containers, networks, volumes, and images with `docker compose down --volumes --rmi all --remove-orphans`; also delete the containers and volumes you started outside Compose for the task. The networks of projects that aren't removed fill Docker's address pool, and new Compose projects can't start.
- When the application stores files in AWS S3, run RustFS as its local stand-in: a `rustfs` service built from `.docker/rustfs/Dockerfile`, which starts from the pinned `rustfs/rustfs` image, with its data in the `rustfs-data` volume. RustFS serves the S3 API on port 9000 and its console on port 9001, and reads its credentials from `RUSTFS_ACCESS_KEY` and `RUSTFS_SECRET_KEY`. Don't use SeaweedFS, MinIO, or LocalStack for it; where a project runs one of them, replace it with RustFS in a task opened for that.
- Keep `.env*`, `.git`, dependency, and build folders out of the build context with the `.dockerignore` at the repository root.
- Use base images with pinned versions, not `latest`; use the same version locally and in prod. In the prod image, use a multi-stage build and a non-root user.
- Define Compose commands in the project's script mechanism (for example `package.json`, `composer.json`, `Makefile`).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.