Skill: austindixson/docker-skill (version 1.0.0)

--- name: docker displayName: Docker description: Installs and uses Docker reliably with official docs. Use when installing Docker (Desktop or Engine), building or running containers, writing Dockerfiles, using docker compose, or when the user asks about containers, images, or Docker CLI. homepage: https://docs.docker.com/ metadata: {"openclaw": {"requires": {"anyBins": ["docker"]}, "install": {"brew": "docker"}, "primaryEnv": null}} --- # Docker — Install and Use Containers Enables OpenClaw (and Cursor) to install Docker and use it reliably. Base all guidance on **official Docker docs**; when in doubt, fetch from canonical URLs below. ## When to Apply - User wants to **install Docker** (macOS, Linux, Windows) - User asks about **containers**, **images**, **Dockerfile**, **docker compose** - Building, running, or debugging **Docker** commands or workflows - User asks for "latest Docker docs" or "how do I use Docker" ## Canonical Documentation URLs | Purpose | URL | |--------|-----| | Get started / overview | https://docs.docker.com/get-started/overview/ | | Get Docker (install) | https://docs.docker.com/get-started/get-docker/ | | Develop with containers | https://docs.docker.com/get-started/introduction/develop-with-containers/ | | Guides | https://docs.docker.com/guides/ | | Manuals (install, config, use) | https://docs.docker.com/manuals/ | | Reference (CLI, Dockerfile, API) | https://docs.docker.com/reference/ | | Engine install (Linux) | https://docs.docker.com/engine/install/ | | Docker Desktop Mac | https://docs.docker.com/desktop/install/mac-install/ | | Docker CLI reference | https://docs.docker.com/reference/cli/docker/ | | Dockerfile reference | https://docs.docker.com/reference/dockerfile/ | **Rule:** For install steps, CLI syntax, or Dockerfile instructions, **fetch the relevant doc URL** and use that content. Do not rely on training data for version-specific install or command details. --- ## Installation (Reliable Paths) ### macOS **Recommended: Docker Desktop** 1. Download from official docs: [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/). - Apple Silicon: `https://desktop.docker.com/mac/main/arm64/Docker.dmg` - Intel: `https://desktop.docker.com/mac/main/amd64/Docker.dmg` 2. Open `Docker.dmg`, drag Docker to Applications, then open Docker.app and accept terms. 3. **CLI install (optional):** After downloading the DMG: ```bash sudo hdiutil attach Docker.dmg sudo /Volumes/Docker/Docker.app/Contents/MacOS/install sudo hdiutil detach /Volumes/Docker ``` 4. Verify: `docker run hello-world` **OpenClaw / automation:** If `docker` is missing and the user is on macOS, suggest installing via Homebrew: `brew install --cask docker`, then starting Docker Desktop so the daemon is running. ### Linux (Ubuntu example) 1. Prefer **Docker Engine from apt** (see [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)). 2. Remove conflicting packages first: ```bash sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc 2>/dev/null | cut -f1) ``` 3. Add Docker’s apt repo, then: ```bash sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo systemctl start docker sudo docker run hello-world ``` 4. Optional (run without sudo): [Linux postinstall](https://docs.docker.com/engine/install/linux-postinstall/) — add user to `docker` group. **Convenience script (dev/test only):** `curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh`. Not recommended for production. ### Windows Use [Get Docker](https://docs.docker.com/get-started/get-docker/) and follow **Docker Desktop for Windows** (WSL2 backend recommended). --- ## Core Workflow: Build and Run 1. **Dockerfile** in app directory (see [reference.md](reference.md) or [Dockerfile reference](https://docs.docker.com/reference/dockerfile/)). 2. **Build image:** `docker build -t <name> .` 3. **Run container:** `docker run -d -p HOST_PORT:CONTAINER_PORT <name>` (e.g. `-p 127.0.0.1:3000:3000`). 4. **List containers:** `docker ps` (running), `docker ps -a` (all). 5. **Stop/remove:** `docker stop <container>`, `docker rm <container>`. Example from official getting-started: ```bash docker build -t getting-started . docker run -d -p 127.0.0.1:3000:3000 getting-started # Open http://localhost:3000 ``` --- ## Daemon Must Be Running - **Docker Desktop (Mac/Windows):** Ensure Docker Desktop app is running; `docker` CLI talks to its daemon. - **Linux:** `sudo systemctl start docker` (and `enable` if needed). - If the user sees "Cannot connect to the Docker daemon", direct them to start Docker Desktop or the engine service and try again. --- ## Quick Reference - **Images:** `docker pull <image>`, `docker images`, `docker rmi <image>` - **Containers:** `docker run`, `docker ps`, `docker stop`, `docker rm`, `docker logs <container>` - **Compose:** `docker compose up -d`, `docker compose down` — use `compose.yaml` in project root (see [Compose file reference](https://docs.docker.com/reference/compose-file/)). - **Cleanup:** `docker system prune -a` (removes unused images/containers/networks; use with care). ## Additional Resources - For detailed CLI and Dockerfile syntax, see [reference.md](reference.md). - For full specs, fetch from the official [reference](https://docs.docker.com/reference/) and [guides](https://docs.docker.com/guides/).

path: reference.md
content: # Docker Reference — CLI and Dockerfile Essentials

Condensed reference for daily use. Full specs: [Docker CLI](https://docs.docker.com/reference/cli/docker/), [Dockerfile](https://docs.docker.com/reference/dockerfile/), [Compose file](https://docs.docker.com/reference/compose-file/).

---

## Docker CLI (frequently used)

| Command | Purpose |
|--------|---------|
| `docker run [OPTIONS] IMAGE [COMMAND]` | Create and start a container |
| `docker run -d` | Run in background (detached) |
| `docker run -p HOST:CONTAINER` | Publish port (e.g. `-p 3000:3000` or `-p 127.0.0.1:3000:3000`) |
| `docker run -it IMAGE CMD` | Interactive TTY (e.g. `docker run -it ubuntu /bin/bash`) |
| `docker run --name NAME` | Set container name |
| `docker run -v HOST:CONTAINER` | Bind mount volume |
| `docker run -e VAR=value` | Set env var |
| `docker build -t TAG [PATH]` | Build image; default path `.` |
| `docker build -f Dockerfile.path .` | Use alternate Dockerfile |
| `docker ps` | List running containers |
| `docker ps -a` | List all containers |
| `docker images` | List images |
| `docker pull IMAGE` | Pull image from registry |
| `docker stop CONTAINER` | Stop container |
| `docker rm CONTAINER` | Remove container |
| `docker rmi IMAGE` | Remove image |
| `docker logs CONTAINER` | Show container logs |
| `docker exec -it CONTAINER CMD` | Run command in running container |
| `docker system prune -a` | Remove unused data (images, containers, networks) |

**Compose (v2 plugin):**

| Command | Purpose |
|--------|---------|
| `docker compose up -d` | Start services in background |
| `docker compose down` | Stop and remove containers/networks |
| `docker compose build` | Build service images |
| `docker compose logs -f` | Follow logs |

---

## Dockerfile essentials

- **Location:** Usually project root, named `Dockerfile` (no extension).
- **Syntax:** `# syntax=docker/dockerfile:1` (optional, recommended for reproducible builds).

| Instruction | Purpose |
|-------------|---------|
| `FROM image[:tag]` | Base image (e.g. `FROM node:24-alpine`) |
| `WORKDIR /path` | Set working directory |
| `COPY src dest` | Copy files from build context (e.g. `COPY . .`) |
| `ADD src dest` | Like COPY but supports URLs/tarballs; prefer COPY when possible |
| `RUN command` | Run command in layer (e.g. `RUN npm install`) |
| `ENV KEY=value` | Set environment variable |
| `EXPOSE port` | Document port (does not publish; use `-p` at run) |
| `CMD ["exec","arg"]` | Default command when container starts (exec form preferred) |
| `ENTRYPOINT ["exec","arg"]` | Fixed entrypoint; CMD becomes args |

**Example (Node app):**

```dockerfile
# syntax=docker/dockerfile:1
FROM node:24-alpine
WORKDIR /app
COPY . .
RUN npm install --omit=dev
CMD ["node", "src/index.js"]
EXPOSE 3000
```

**Best practices:** Use specific tags (e.g. `node:24-alpine`), order instructions to maximize cache (deps before app copy), use `.dockerignore` to exclude unneeded files.

---

## Compose file (minimal)

Default file: `compose.yaml` or `docker-compose.yaml` in project root.

```yaml
services:
  app:
    build: .
    ports:
      - "127.0.0.1:3000:3000"
    environment:
      - NODE_ENV=production
  # db:
  #   image: postgres:16-alpine
  #   volumes:
  #     - dbdata:/var/lib/postgresql/data
# volumes:
#   dbdata:
```

Run: `docker compose up -d`. Full spec: [Compose file reference](https://docs.docker.com/reference/compose-file/).

---

## Troubleshooting

- **"Cannot connect to the Docker daemon"** — Start Docker Desktop (Mac/Windows) or `sudo systemctl start docker` (Linux).
- **Permission denied (Linux)** — Add user to `docker` group: `sudo usermod -aG docker $USER`; log out/in or `newgrp docker`.
- **Port already in use** — Change host port in `-p` (e.g. `-p 127.0.0.1:3001:3000`) or stop the process using the port.
- **Build context too large** — Add entries to `.dockerignore` (e.g. `node_modules`, `.git`, `*.log`).

For more, see [Docker troubleshooting](https://docs.docker.com/desktop/troubleshoot-and-support/troubleshoot/) and [reference](https://docs.docker.com/reference/).


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (HIGH)