Get the FREE Ultimate OpenClaw Setup Guide →

docker-ops

npx machina-cli add skill agenticdevops/devops-execution-engine/docker-ops --openclaw
Files (1)
SKILL.md
4.5 KB

Docker Operations

Quick reference for Docker container management and debugging.

When to Use This Skill

Use this skill when:

  • Managing Docker containers
  • Debugging container issues
  • Checking container logs
  • Cleaning up Docker resources
  • Inspecting container state

Quick Status Commands

List Containers

# Running containers
docker ps

# All containers (including stopped)
docker ps -a

# With size info
docker ps -s

# Custom format
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

Container Logs

# View logs
docker logs <container>

# Follow logs (live)
docker logs -f <container>

# Last N lines
docker logs --tail 100 <container>

# With timestamps
docker logs -t <container>

# Since time
docker logs --since 1h <container>

Resource Usage

# Live stats for all containers
docker stats

# One-time stats (no stream)
docker stats --no-stream

# Specific container
docker stats <container>

Container Management

Start/Stop/Restart

# Start stopped container
docker start <container>

# Stop running container
docker stop <container>

# Restart container
docker restart <container>

# Kill (force stop)
docker kill <container>

Execute Commands

# Run command in container
docker exec <container> <command>

# Interactive shell
docker exec -it <container> /bin/sh
docker exec -it <container> /bin/bash

# As root
docker exec -u root -it <container> /bin/sh

Inspect Container

# Full inspect output
docker inspect <container>

# Get specific field
docker inspect -f '{{.State.Status}}' <container>
docker inspect -f '{{.NetworkSettings.IPAddress}}' <container>
docker inspect -f '{{json .Config.Env}}' <container>

Image Management

List Images

# All images
docker images

# With digests
docker images --digests

# Dangling images only
docker images -f "dangling=true"

Pull/Push

# Pull image
docker pull <image>:<tag>

# Push image
docker push <image>:<tag>

Cleanup Commands

Safe Cleanup

# Remove stopped containers
docker container prune -f

# Remove unused images
docker image prune -f

# Remove unused volumes
docker volume prune -f

# Remove unused networks
docker network prune -f

# Full system cleanup (safe - only unused)
docker system prune -f

Check Disk Usage

# Docker disk usage summary
docker system df

# Detailed breakdown
docker system df -v

Debugging

Container Not Starting

# Check container state
docker inspect -f '{{.State.Status}}' <container>
docker inspect -f '{{.State.Error}}' <container>

# Check logs
docker logs <container>

# Check events
docker events --since 1h --filter container=<container>

Network Issues

# List networks
docker network ls

# Inspect network
docker network inspect <network>

# Check container network
docker inspect -f '{{json .NetworkSettings.Networks}}' <container>

# Test connectivity from container
docker exec <container> ping -c 3 <host>
docker exec <container> curl -v <url>

Resource Issues

# Check container resource limits
docker inspect -f '{{.HostConfig.Memory}}' <container>
docker inspect -f '{{.HostConfig.CpuShares}}' <container>

# Live resource usage
docker stats <container> --no-stream

Common Patterns

Run One-Off Command

# Run and remove after
docker run --rm <image> <command>

# Example: check version
docker run --rm alpine cat /etc/alpine-release

Copy Files

# Copy from container to host
docker cp <container>:/path/to/file ./local/path

# Copy from host to container
docker cp ./local/file <container>:/path/in/container

View Container Processes

# Processes in container
docker top <container>

Quick Troubleshooting

SymptomCheckFix
Container exits immediatelydocker logs <container>Fix application error
Can't connect to containerdocker inspect networkCheck port mapping
Container slowdocker statsIncrease resources
Disk fulldocker system dfdocker system prune
Image pull failsNetwork/authCheck registry access

Related Skills

  • k8s-debug: For Kubernetes container debugging
  • log-analysis: For log pattern analysis

Source

git clone https://github.com/agenticdevops/devops-execution-engine/blob/main/skills/docker-ops/SKILL.mdView on GitHub

Overview

Provides a concise reference for managing Docker containers, viewing logs, inspecting state, and cleaning up resources. It helps engineers diagnose issues faster and keep container environments healthy and efficient.

How This Skill Works

The skill leverages common Docker CLI commands (ps, logs, inspect, stats, exec, prune, etc.) organized into practical workflows. You observe container state, gather diagnostics, and perform maintenance tasks through targeted commands.

When to Use It

  • Managing Docker containers
  • Debugging container issues
  • Checking container logs
  • Cleaning up Docker resources
  • Inspecting container state

Quick Start

  1. Step 1: List containers to identify targets: docker ps -a
  2. Step 2: Inspect and view logs: docker inspect <container> and docker logs -f <container>
  3. Step 3: Take action: docker restart <container> or docker exec -it <container> /bin/sh

Best Practices

  • Start with a quick status check using docker ps -a (optionally with --format) to identify targets.
  • Tail logs with docker logs -f for real-time debugging and capturing events.
  • Use docker inspect to verify state, IP addresses, and configuration before taking action.
  • Prune unused resources with care and document what was removed (e.g., docker system prune -f).
  • Monitor resource usage with docker stats and apply appropriate limits to prevent thrashing.

Example Use Cases

  • Restart a failing container after inspecting state and logs.
  • Diagnose and fix a network issue by inspecting networks and testing connectivity from the container.
  • Identify CPU/memory contention with docker stats and tune container limits.
  • Clean up stale containers, images, volumes, and networks with prune commands.
  • Retrieve container IPs and environment variables with docker inspect for troubleshooting.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers