Docker Cli
by @openlang-cn
Helper for using the Docker CLI to build, run, stop, inspect, and manage containers and images. Use when the user wants to perform container-related tasks fr...
clawhub install docker-cliπ About This Skill
name: docker-cli description: Helper for using the Docker CLI to build, run, stop, inspect, and manage containers and images. Use when the user wants to perform container-related tasks from the command line, such as building images, running services, cleaning up resources, or checking logs.
Docker CLI Helper
This skill explains how to use the Docker command line for common container workflows.
When to Use
Use this skill when:
Requirements
docker version or docker info works in the userβs shell.If unsure, suggest the user run:
docker version
to confirm Docker is available.
Safety Guidelines
docker ps, docker ps -a
- docker images
- docker logs
- docker inspect
docker rm, docker rmi
- docker system prune
- docker volume rm
Common Workflows
1. List and inspect containers
List running containers:
docker ps
List all containers (including stopped):
docker ps -a
Inspect a container in detail:
docker inspect
2. List and inspect images
List local images:
docker images
Inspect an image:
docker inspect
3. Build images
Build an image from a Dockerfile in the current directory:
docker build -t : .
Example:
docker build -t my-app:latest .
If the Dockerfile is in another directory:
docker build -t my-app:latest path/to/context
4. Run containers
Run a container in the foreground:
docker run --rm -it :
Run in detached mode (background service):
docker run -d --name :
Map ports from container to host:
docker run -d --name -p 8080:80 :
Mount a host directory into the container:
docker run -d --name -v /host/path:/container/path :
5. Stop and remove containers
Stop a running container:
docker stop
Remove a stopped container:
docker rm
Stop and remove in one shot (two commands):
docker stop
docker rm
6. Remove images
Remove an image by ID or name:
docker rmi
Only suggest this when the user is sure the image is no longer needed.
7. Logs and exec
See logs for a container:
docker logs
Stream logs (follow):
docker logs -f
Execute a shell inside a running container (if it has /bin/bash):
docker exec -it /bin/bash
or with /bin/sh:
docker exec -it /bin/sh
8. Clean up resources
Only suggest these when the user explicitly wants cleanup:
docker container prune
docker image prune
docker system prune
For a more aggressive cleanup, but only if the user confirms:
docker system prune -a
Troubleshooting Tips
-p host:container.
- Or stopping the process that currently uses the port.
docker logs for errors.
- Inspect entrypoint and command configuration.