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"
When running inside Docker Test: The test container already has the Docker CLI and the host socket mounted. Use docker directly to create, run, stop, and remove containers; do not try to install Docker or use sudo. See LEARNINGS.md (Integration with Docker Test).
Canonical Documentation URLs
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
Install Docker on the host so the docker CLI and daemon are available. After install, ensure the daemon is running (docker run hello-world).
Installation (reliable paths)
macOS
Recommended: Docker Desktop
- Download from official docs: Install Docker Desktop on Mac.
- Apple Silicon:
https://desktop.docker.com/mac/main/arm64/Docker.dmg
- Intel:
https://desktop.docker.com/mac/main/amd64/Docker.dmg
- Open
Docker.dmg, drag Docker to Applications, then open Docker.app and accept terms.
- CLI install (optional): After downloading the DMG:
sudo hdiutil attach Docker.dmg
sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
sudo hdiutil detach /Volumes/Docker
- 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)
- Prefer Docker Engine from apt (see Install Docker Engine on Ubuntu).
- Remove conflicting packages first:
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc 2>/dev/null | cut -f1)
- Add Docker’s apt repo, then:
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
- Optional (run without sudo): 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 and follow Docker Desktop for Windows (WSL2 backend recommended).
Core Workflow: Build and Run
- Dockerfile in app directory (see reference.md or Dockerfile reference). If any path in COPY has spaces, quote it (e.g.
COPY . "/app/Docker Skill").
- Build image:
docker build -t <name> .
- Run container:
docker run -d -p HOST_PORT:CONTAINER_PORT <name> (e.g. -p 127.0.0.1:3000:3000).
- List containers:
docker ps (running), docker ps -a (all).
- Stop/remove:
docker stop <container>, docker rm <container>.
Example from official getting-started:
docker build -t getting-started .
docker run -d -p 127.0.0.1:3000:3000 getting-started
# Open http://localhost:3000
Usage examples
Run a one-off command and remove the container:
docker run --rm alpine echo "Hello from Alpine"
Create, run, then stop and remove a named container:
docker run --name my-test alpine echo "test"
docker stop my-test
docker rm my-test
Pull an image, run a minimal container, then remove container and image:
docker run --name hello hello-world
docker rm hello
docker rmi hello-world
Build and run a web app (port mapping):
docker build -t myapp .
docker run -d -p 127.0.0.1:3000:3000 myapp
docker ps
docker stop <container_id>
docker rm <container_id>
Compose (multi-service):
docker compose up -d
docker compose logs -f
docker compose down
Daemon Must Be Running
- Docker Desktop (Mac/Windows): Ensure Docker Desktop app is running;
docker CLI talks to its daemon.
- Colima (macOS): If using Colima instead of Docker Desktop, set
DOCKER_HOST (e.g. unix://$HOME/.colima/default/docker.sock) so the CLI and scripts find the 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).
- Cleanup:
docker system prune -a (removes unused images/containers/networks; use with care).
Volume mounts
When using -v HOST:CONTAINER, use stable host paths (e.g. a directory under the project or skill root). Avoid temporary directories (e.g. from mktemp); they may not mount reliably in some environments (sandboxes, CI, remote Docker). See LEARNINGS.md.
Additional Resources
- For detailed CLI and Dockerfile syntax, see reference.md.
- For full specs, fetch from the official reference and guides.
- For volume-mount and environment learnings, see LEARNINGS.md.
1---
2name: docker
3displayName: Docker
4description: 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.
5homepage: https://docs.docker.com/
6metadata:
7 source: https://skillmd.com/skills/modbender/docker
8 openclaw:
9 requires:
10 anyBins:
11 - docker
12 install:
13 brew: docker
14 primaryEnv: null
15---
16
17# Docker — Install and Use Containers
18
19Enables 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.
20
21## When to Apply
22
23- User wants to **install Docker** (macOS, Linux, Windows)
24- User asks about **containers**, **images**, **Dockerfile**, **docker compose**
25- Building, running, or debugging **Docker** commands or workflows
26- User asks for "latest Docker docs" or "how do I use Docker"
27
28**When running inside Docker Test:** The test container already has the Docker CLI and the host socket mounted. Use `docker` directly to create, run, stop, and remove containers; do not try to install Docker or use sudo. See [LEARNINGS.md](LEARNINGS.md) (Integration with Docker Test).
29
30## Canonical Documentation URLs
31
32| Purpose | URL |
33|--------|-----|
34| Get started / overview | https://docs.docker.com/get-started/overview/ |
35| Get Docker (install) | https://docs.docker.com/get-started/get-docker/ |
36| Develop with containers | https://docs.docker.com/get-started/introduction/develop-with-containers/ |
37| Guides | https://docs.docker.com/guides/ |
38| Manuals (install, config, use) | https://docs.docker.com/manuals/ |
39| Reference (CLI, Dockerfile, API) | https://docs.docker.com/reference/ |
40| Engine install (Linux) | https://docs.docker.com/engine/install/ |
41| Docker Desktop Mac | https://docs.docker.com/desktop/install/mac-install/ |
42| Docker CLI reference | https://docs.docker.com/reference/cli/docker/ |
43| Dockerfile reference | https://docs.docker.com/reference/dockerfile/ |
44
45**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.
46
47---
48
49## Installation
50
51Install Docker on the host so the `docker` CLI and daemon are available. After install, ensure the daemon is running (`docker run hello-world`).
52
53### Installation (reliable paths)
54
55### macOS
56
57**Recommended: Docker Desktop**
58
591. Download from official docs: [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/).
60 - Apple Silicon: `https://desktop.docker.com/mac/main/arm64/Docker.dmg`
61 - Intel: `https://desktop.docker.com/mac/main/amd64/Docker.dmg`
622. Open `Docker.dmg`, drag Docker to Applications, then open Docker.app and accept terms.
633. **CLI install (optional):** After downloading the DMG:
64 ```bash
65 sudo hdiutil attach Docker.dmg
66 sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
67 sudo hdiutil detach /Volumes/Docker
68 ```
694. Verify: `docker run hello-world`
70
71**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.
72
73### Linux (Ubuntu example)
74
751. Prefer **Docker Engine from apt** (see [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)).
762. Remove conflicting packages first:
77 ```bash
78 sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc 2>/dev/null | cut -f1)
79 ```
803. Add Docker’s apt repo, then:
81 ```bash
82 sudo apt update
83 sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
84 sudo systemctl start docker
85 sudo docker run hello-world
86 ```
874. Optional (run without sudo): [Linux postinstall](https://docs.docker.com/engine/install/linux-postinstall/) — add user to `docker` group.
88
89**Convenience script (dev/test only):** `curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh`. Not recommended for production.
90
91### Windows
92
93Use [Get Docker](https://docs.docker.com/get-started/get-docker/) and follow **Docker Desktop for Windows** (WSL2 backend recommended).
94
95---
96
97## Core Workflow: Build and Run
98
991. **Dockerfile** in app directory (see [reference.md](reference.md) or [Dockerfile reference](https://docs.docker.com/reference/dockerfile/)). If any path in COPY has spaces, quote it (e.g. `COPY . "/app/Docker Skill"`).
1002. **Build image:** `docker build -t <name> .`
1013. **Run container:** `docker run -d -p HOST_PORT:CONTAINER_PORT <name>` (e.g. `-p 127.0.0.1:3000:3000`).
1024. **List containers:** `docker ps` (running), `docker ps -a` (all).
1035. **Stop/remove:** `docker stop <container>`, `docker rm <container>`.
104
105Example from official getting-started:
106
107```bash
108docker build -t getting-started .
109docker run -d -p 127.0.0.1:3000:3000 getting-started
110# Open http://localhost:3000
111```
112
113## Usage examples
114
115- **Run a one-off command and remove the container:**
116 ```bash
117 docker run --rm alpine echo "Hello from Alpine"
118 ```
119
120- **Create, run, then stop and remove a named container:**
121 ```bash
122 docker run --name my-test alpine echo "test"
123 docker stop my-test
124 docker rm my-test
125 ```
126
127- **Pull an image, run a minimal container, then remove container and image:**
128 ```bash
129 docker run --name hello hello-world
130 docker rm hello
131 docker rmi hello-world
132 ```
133
134- **Build and run a web app (port mapping):**
135 ```bash
136 docker build -t myapp .
137 docker run -d -p 127.0.0.1:3000:3000 myapp
138 docker ps
139 docker stop <container_id>
140 docker rm <container_id>
141 ```
142
143- **Compose (multi-service):**
144 ```bash
145 docker compose up -d
146 docker compose logs -f
147 docker compose down
148 ```
149
150---
151
152## Daemon Must Be Running
153
154- **Docker Desktop (Mac/Windows):** Ensure Docker Desktop app is running; `docker` CLI talks to its daemon.
155- **Colima (macOS):** If using Colima instead of Docker Desktop, set `DOCKER_HOST` (e.g. `unix://$HOME/.colima/default/docker.sock`) so the CLI and scripts find the daemon.
156- **Linux:** `sudo systemctl start docker` (and `enable` if needed).
157- If the user sees "Cannot connect to the Docker daemon", direct them to start Docker Desktop or the engine service and try again.
158
159---
160
161## Quick Reference
162
163- **Images:** `docker pull <image>`, `docker images`, `docker rmi <image>`
164- **Containers:** `docker run`, `docker ps`, `docker stop`, `docker rm`, `docker logs <container>`
165- **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/)).
166- **Cleanup:** `docker system prune -a` (removes unused images/containers/networks; use with care).
167
168## Volume mounts
169
170When using `-v HOST:CONTAINER`, use **stable host paths** (e.g. a directory under the project or skill root). Avoid temporary directories (e.g. from `mktemp`); they may not mount reliably in some environments (sandboxes, CI, remote Docker). See [LEARNINGS.md](LEARNINGS.md).
171
172## Additional Resources
173
174- For detailed CLI and Dockerfile syntax, see [reference.md](reference.md).
175- For full specs, fetch from the official [reference](https://docs.docker.com/reference/) and [guides](https://docs.docker.com/guides/).
176- For volume-mount and environment learnings, see [LEARNINGS.md](LEARNINGS.md).