Manage Docker containers, images, and compose stacks. Use this skill to list containers, view logs, clean up resources, and manage multi-container applications.
Install
npx skillscat add hrdtbs/agent-skills/docker Install via the SkillsCat registry.
Docker
Interact with Docker containers and images using the Docker CLI. This skill provides best practices for managing containers, inspecting logs, cleaning up unused resources, and using Docker Compose.
For detailed usage and commands, refer to the official Docker documentation.
Usage
Run docker commands directly.
docker [subcommand] [flags]Common Operations
List Containers
Use formatting to get a clean table view of running containers.
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}"To list all containers (including stopped ones):
docker ps -a --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}"View Logs
Follow logs for a specific container, limiting the output to the last 100 lines to avoid flooding the console.
docker logs --tail 100 -f <container_name_or_id>Inspect a Container
Get detailed information about a container in JSON format.
docker inspect <container_name_or_id>Clean Up Resources
Remove unused data (stopped containers, unused networks, and dangling images). Be careful with this command.
docker system prune -fTo remove all unused images, not just dangling ones:
docker system prune -a -fExecute Command in Container
Run an interactive shell inside a running container.
docker exec -it <container_name_or_id> /bin/bash
# or if bash is not available:
docker exec -it <container_name_or_id> /bin/shDocker Compose
Manage multi-container applications defined in docker-compose.yml or compose.yml.
Start Services
Start services in the background.
docker compose up -dView Compose Logs
View logs for all services in the compose stack.
docker compose logs --tail 100 -fStop Services
Stop and remove containers, networks, and volumes defined in the compose file.
docker compose downTroubleshooting
- Permission Denied: If you encounter permission errors, ensure the user is in the
dockergroup or try usingsudo(thoughsudousage depends on environment configuration). - Daemon Not Running: If
dockercommands fail with "Cannot connect to the Docker daemon", ensure the Docker service is running (sudo service docker startor equivalent).