OpenClaw skill
docker-essentials
An OpenClaw skill that provides agents with tools to manage Docker containers, images, volumes, and networks. It includes commands such as docker ps, docker images, docker run, docker volume ls, and docker network ls. The skill enables essential Docker operations directly within agent workflows.
Files
Review the files below to add this skill to your agents.
Security notice: review the SKILL.md file and repository content first before using any third-party skill.
SKILL.md content
---
name: docker-essentials
description: Essential Docker commands and workflows for container management, image operations, and debugging.
homepage: https://docs.docker.com/
metadata: {"clawdbot":{"emoji":"🐳","requires":{"bins":["docker"]}}}
---
# Docker Essentials
Essential Docker commands for container and image management.
## Container Lifecycle
### Running containers
```bash
# Run container from image
docker run nginx
# Run in background (detached)
docker run -d nginx
# Run with name
docker run --name my-nginx -d nginx
# Run with port mapping
docker run -p 8080:80 -d nginx
# Run with environment variables
docker run -e MY_VAR=value -d app
# Run with volume mount
docker run -v /host/path:/container/path -d app
# Run with auto-remove on exit
docker run --rm alpine echo "Hello"
# Interactive terminal
docker run -it ubuntu bash
```
### Managing containers
```bash
# List running containers
docker ps
# List all containers (including stopped)
docker ps -a
# Stop container
docker stop container_name
# Start stopped container
docker start container_name
# Restart container
docker restart container_name
# Remove container
docker rm container_name
# Force remove running container
docker rm -f container_name
# Remove all stopped containers
docker container prune
```
## Container Inspection & Debugging
### Viewing logs
```bash
# Show logs
docker logs container_name
# Follow logs (like tail -f)
docker logs -f container_name
# Last 100 lines
docker logs --tail 100 container_name
# Logs with timestamps
docker logs -t container_name
```
### Executing commands
```bash
# Execute command in running container
docker exec container_name ls -la
# Interactive shell
docker exec -it container_name bash
# Execute as specific user
docker exec -u root -it container_name bash
# Execute with environment variable
docker exec -e VAR=value container_name env
```
### Inspection
```bash
# Inspect container details
docker inspect container_name
# Get specific field (JSON path)
docker inspect -f '{{.NetworkSettings.IPAddress}}' container_name
# View container stats
docker stats
# View specific container stats
docker stats container_name
# View processes in container
docker top container_name
```
## Image Management
### Building images
```bash
# Build from Dockerfile
docker build -t myapp:1.0 .
# Build with custom Dockerfile
docker build -f Dockerfile.dev -t myapp:dev .
# Build with build args
docker build --build-arg VERSION=1.0 -t myapp .
# Build without cache
docker build --no-cache -t myapp .
```
### Managing images
```bash
# List images
docker images
# Pull image from registry
docker pull nginx:latest
# Tag image
docker tag myapp:1.0 myapp:latest
# Push to registry
docker push myrepo/myapp:1.0
# Remove image
docker rmi image_name
# Remove unused images
docker image prune
# Remove all unused images
docker image prune -a
```
## Docker Compose
### Basic operations
```bash
# Start services
docker-compose up
# Start in background
docker-compose up -d
# Stop services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# View logs
docker-compose logs
# Follow logs for specific service
docker-compose logs -f web
# Scale service
docker-compose up -d --scale web=3
```
### Service management
```bash
# List services
docker-compose ps
# Execute command in service
docker-compose exec web bash
# Restart service
docker-compose restart web
# Rebuild service
docker-compose build web
# Rebuild and restart
docker-compose up -d --build
```
## Networking
```bash
# List networks
docker network ls
# Create network
docker network create mynetwork
# Connect container to network
docker network connect mynetwork container_name
# Disconnect from network
docker network disconnect mynetwork container_name
# Inspect network
docker network inspect mynetwork
# Remove network
docker network rm mynetwork
```
## Volumes
```bash
# List volumes
docker volume ls
# Create volume
docker volume create myvolume
# Inspect volume
docker volume inspect myvolume
# Remove volume
docker volume rm myvolume
# Remove unused volumes
docker volume prune
# Run with volume
docker run -v myvolume:/data -d app
```
## System Management
```bash
# View disk usage
docker system df
# Clean up everything unused
docker system prune
# Clean up including unused images
docker system prune -a
# Clean up including volumes
docker system prune --volumes
# Show Docker info
docker info
# Show Docker version
docker version
```
## Common Workflows
**Development container:**
```bash
docker run -it --rm \
-v $(pwd):/app \
-w /app \
-p 3000:3000 \
node:18 \
npm run dev
```
**Database container:**
```bash
docker run -d \
--name postgres \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=mydb \
-v postgres-data:/var/lib/postgresql/data \
-p 5432:5432 \
postgres:15
```
**Quick debugging:**
```bash
# Shell into running container
docker exec -it container_name sh
# Copy file from container
docker cp container_name:/path/to/file ./local/path
# Copy file to container
docker cp ./local/file container_name:/path/in/container
```
**Multi-stage build:**
```dockerfile
# Dockerfile
FROM node:18 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
```
## Useful Flags
**`docker run` flags:**
- `-d`: Detached mode (background)
- `-it`: Interactive terminal
- `-p`: Port mapping (host:container)
- `-v`: Volume mount
- `-e`: Environment variable
- `--name`: Container name
- `--rm`: Auto-remove on exit
- `--network`: Connect to network
**`docker exec` flags:**
- `-it`: Interactive terminal
- `-u`: User
- `-w`: Working directory
## Tips
- Use `.dockerignore` to exclude files from build context
- Combine `RUN` commands in Dockerfile to reduce layers
- Use multi-stage builds to reduce image size
- Always tag your images with versions
- Use `--rm` for one-off containers
- Use `docker-compose` for multi-container apps
- Clean up regularly with `docker system prune`
## Documentation
Official docs: https://docs.docker.com/
Dockerfile reference: https://docs.docker.com/engine/reference/builder/
Compose file reference: https://docs.docker.com/compose/compose-file/
How this skill works
- The skill accepts natural language tasks describing Docker operations
- It classifies the task into one of five actions: pull, run, ps, stop, or rm
- It extracts required parameters such as image name, container name, and options from the task
- It constructs and executes the corresponding Docker CLI command
- It captures the command's stdout, stderr, and exit code
- It returns a JSON object containing success status, message, and output
When to use it
- When listing running or all Docker containers
- When listing available Docker images
- When pulling a Docker image from a registry
- When building a Docker image from a Dockerfile
- When running a new Docker container from an image
- When stopping a running Docker container
- When removing a stopped Docker container
- When executing a command inside a running Docker container
- When listing Docker volumes
- When creating a Docker volume
Best practices
- Install Docker and ensure the daemon is running before using the skill
- Verify Docker CLI is accessible from the PATH
- Use `docker_stop` before `docker_rm` for graceful container shutdown
- Check for port conflicts before using `docker_run` with port mappings
Example use cases
- Pulling a Docker image: Pulls the nginx Docker image using docker_pull('nginx').
- Running an Nginx container: Runs an nginx container with port mapping using docker_run('nginx', ports='80:80').
- Listing running containers: Lists currently running Docker containers using docker_ps().
- Stopping a container: Stops a specific Docker container by ID using docker_stop('abc123').
- Viewing container logs: Retrieves logs from a specific Docker container using docker_logs('abc123').
FAQs
What is the overview of the docker-essentials skill?
This skill provides fundamental Docker commands for managing containers and images. It is designed for OpenClaw agents to interact with Docker environments securely.
What are the prerequisites for the docker-essentials skill?
Docker installed and daemon running. User has Docker permissions (docker group or root).
What tools are provided by the docker-essentials skill?
list_containers, list_images, pull_image, run_container, stop_container, remove_container.
What does the list_containers tool do?
List all Docker containers (running and stopped).
What parameters does list_containers accept?
all: bool (default: false) - Show all containers, not just running.
What does the list_images tool do?
List all Docker images.
What parameters does list_images accept?
none
What does the pull_image tool do?
Pull a Docker image from registry.
What parameters does pull_image accept?
image: str - Image name (e.g., "nginx:latest")
What does the run_container tool do?
Run a new container from an image.
What parameters does run_container accept?
image: str, command: str (optional), detach: bool (default: true), name: str (optional)
What does the stop_container tool do?
Stop a running container.
What parameters does stop_container accept?
container_id: str
What does the remove_container tool do?
Remove a stopped container.
What parameters does remove_container accept?
container_id: str, force: bool (default: false)
What are the security notes for the docker-essentials skill?
Runs Docker commands via subprocess. Ensure agent context is trusted.
More similar skills to explore
- achurch
An OpenClaw skill for church administration that handles member management, event scheduling, sermon retrieval, and donation processing. It provides tools to list members, add new members, schedule events, fetch sermons, and record donations.
- agent-config
An OpenClaw skill that enables agents to manage their configuration by loading from files, environment variables, or remote sources. It supports retrieving, setting, and validating configuration values. The skill allows for hot-reloading of configurations.
- agent-council
An OpenClaw skill named agent-council that enables the primary agent to summon a council of specialized sub-agents for deliberating on tasks. The council members discuss the query from unique perspectives, propose solutions, and vote to select the best response. The skill outputs the winning proposal with supporting rationale from the council.
- agent-identity-kit
An OpenClaw skill that equips agents with tools to craft, manage, and evolve digital identities, including generating personas, bios, avatars, and communication styles. It supports creating detailed agent personas with name, background, goals, personality traits; crafting bios for specific platforms; designing avatars; tuning voice and style; and adapting identities to new contexts.
- agenticflow-skill
An OpenClaw skill that provides tools for interacting with Agentic Flow. The tools enable agents to create agentic flows with defined tasks, execute existing flows, and retrieve flow status and outputs.
- agentlens
AgentLens is an OpenClaw skill that enables agents to inspect the internal cognition and actions of other agents. It provides visibility into reasoning traces (thoughts), tool calls and arguments, retrieved memories, and response generation. The skill supports analysis in multi-agent conversations via the "inspect" action targeting a specific agent.