docker-cli
Skill2 starsChanged 8 months agoMITView on GitHub
Expert Docker CLI reference — containers, images, buildx, compose, networking, volumes, security, multi-platform builds, and troubleshooting. Use this when working with docker containers. Triggers on: docker, container, image, volume, network, compose, Dockerfile, build, pull, push, registry, docker-compose, K8s migration, k3d, kind.
- Reads credentials
- Deletes or force-pushes
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- julweber/ai_agent_skillsword for word, first seen Mar 20, 2026
- itsnex1s/awesome-claude-skillstheir own version, first seen Jan 13, 2026
Other versions2 projects use a version of this.
Word for word · 1
- julweber/ai_agent_skills★ 2100% same
Edited · 0
None found.
Wrote their own version · 1
- itsnex1s/awesome-claude-skills★ 5same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository51 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-agent-skills-assistantSkill
- ansibleSkill
- artificial-analysisSkill
- cavemanSkill
- claude-cliSkill
- code-doctorSkill
- code-summarizerSkill
- codex-cliSkill
- concourse-ciSkill
- dev-brainstormingSkill
- file-organizerSkill
- frontend-web-developerSkill
- github-actions-cicdSkill
- github-cliSkill
- gitlab-ci-cdSkill
- grill-meSkill
- gtd-assistantSkill
- herdr-cliSkill
- hf-cliSkill
- karpathy-guidelinesSkill
- kestraSkill
- list-large-filesSkill
- list-most-intensive-processesSkill
- llama-cppSkill
- llm-wikiSkill
- mermaidSkill
- morning-ritualSkill
- obsidian-masterSkill
- obsidian-open-loops-collectorSkill
- opencode-agent-creatorSkill
- opencode-cliSkill
- pi-cliSkill
- pi-subagents-masterSkill
- planka-development-flowSkill
- plnk-cliSkill
- ponytailSkill
- product-prd-brainstormingSkill
- python-api-developerSkill
- ralph-prd-converterSkill
- ralph-prd-generatorSkill
- release-managementSkill
- rest-testsuite-skillSkill
- skill-loaderSkill
- design-taste-frontendSkill
- terraformSkill
- tmux-coderSkill
- tmux-specialistSkill
- trello-cliSkill
- tts-conversationSkill
- uvSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 112
Use .dockerignore to exclude unnecessary files from the build context
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docker CLI Skill
You are an expert at the docker and docker-compose CLIs — including modern BuildKit features via buildx. Use these tools to manage containers, images, networks, volumes, and multi-service deployments.
Reference Documents
- Full CLI cheat sheet —
references/cheat-sheet.md. Covers every command, flag, and option across all Docker subcommands (containers, images, buildx, compose, networking, volumes, swarm, plugins, context, system).
Quick Reference: Most Common Commands
# Container lifecycle
docker run -d --name myapp nginx # detached container
docker ps # running only
docker ps -a # all containers
docker logs -f <container> # follow logs
docker exec -it <container> sh # interactive shell
docker stop/start/rm <container>
# Build & Images
docker buildx build -t myapp:latest . --load # modern build with cache
docker pull/push myimage # registry operations
docker image prune -a -f # clean unused images
# Compose (multi-service)
docker compose up -d # start all services
docker compose down # stop & remove everything
docker compose --profile dev up # profile-based startupContainer Lifecycle: run / start / stop / rm
Running a container — key options by use case
Basic execution: -d -i -t -a/-A (detach, interactive stdin, pseudo-TTY)
Networking & ports:
-p 80:80 -p 443:443 # host port mapping
--network mynet --name myapp # user-defined network + aliasVolumes & filesystems:
-v data:/data # named volume
-v $(pwd)/src:/usr/src/app:ro # bind mount (read-only)
--mount type=bind,source=/host,target=/container # extended syntaxResources — control CPU/memory/disk I/O and limits:
-c 512 # relative CPU shares (0–default; higher = more CPU)
--cpus=4 # hard cap: number of CPUs
--memory=4g --memory-reservation=3g # memory limit + soft reservation
-m 4g # shorthand for memory
# Device I/O limits
--device-read-bps /dev/sda:10mb # read rate from device
--device-write-iops /dev/vdb:500 # write IO/s limit on deviceSecurity & isolation:
-u root # run as specific user (uid:gid format)
--userns=host # share host's user namespace
--security-opt=no-new-privileges:true # prevent privilege escalation
--cap-add=NET_ADMIN # add Linux capability
--privileged # full access (avoid in prod)
--read-only # read-only rootfs
--init # init process for signal forwarding + zombie reapingHealthchecks (critical for reliability):
--health-cmd="curl -f http://localhost/ || exit 1" # check command
--health-interval=30s # how often to run
--health-start-period=60s # grace period before retries count
--health-retries=3 # consecutive failures to declare unhealthyRestart policies: --restart=on-failure:5 | always | unless-stopped | no (default)
Dockerfile Best Practices
Writing efficient Dockerfiles
Multi-stage builds — separate build environment from runtime to reduce image size:
# Build stage
FROM golang:1.22-bookworm AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -o myapp .
# Runtime stage
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/myapp /usr/local/bin/myapp
USER 1000:1000
ENTRYPOINT ["myapp"]Layer caching strategy — order instructions to maximize cache hits:
- Copy
go.mod/package.json/requirements.txtfirst, thenRUN install - Copy application source code last (changes most frequently)
- Use
.dockerignoreto exclude unnecessary files from the build context
.dockerignore essentials:
.git
.gitignore
node_modules
__pycache__
*.md
.env
.dockerignore
Dockerfile
dist
buildBuild & Images: buildx / image
Building images — modern build pipeline via docker buildx
BuildKit offers parallel stages, cache management, multi-platform builds, and security attestations.
# Standard build with cache
docker buildx build -t myapp:latest . --load # load to local docker (default)
docker buildx build -t myapp:latest . --push # push directly to registry
docker buildx build -t myapp:latest . --output=type=local,dest=. # output as tarball
# Multi-platform
docker buildx build --platform linux/amd64,linux/arm64 -t myapp:multi . --push
# Caching strategies
--cache-from type=registry,ref=myapp:cache # pull cache from registry
--cache-to type=local,dest=/tmp/build-cache # export to directory
--cache-to type=inline # inline cache (embedded in image)
# BuildKit features
--build-arg BUILDKIT_INLINE_CACHE=1 # enable inline caching in Dockerfile
--secret id=mykey,src=./private_key # mount secrets at build time
--ssh default # expose SSH agent for private deps
# Security attestations (SLSA compliance)
--attest type=provenance,mode=max,version=v1 # build provenance metadata
--attest type=sbom # software bill of materials
--provenance=mode=max # shorthand for provenance
--sbom # shorthand for SBOM
# BuildKit advanced options
--build-context name=base,src=../shared-library # additional build contexts
--target builder # build to a specific stage
--iidfile image-id.txt # write image ID to file
--metadata-file build-meta.json # write build metadataImage management: pull / push / inspect / prune / tag
docker image inspect --format='{{json .Config.Env}}' myimage # query metadata
docker history myimage -v # layer sizes & diff
docker save myimage:tag -o ./myimage.tar # export for offline use
docker load -i myimage.tar # import from archive
# Tagging & pushing to registries
docker tag myapp:latest registry.example.com/myapp:v1.2.3 # tag for registry
docker push registry.example.com/myapp:v1.2.3 # push specific tag
docker push registry.example.com/myapp:v1.2.3 --all-tags # push all tags
docker pull registry.example.com/myapp:v1.2.3 --platform linux/amd64 # pull for specific archBake mode (YAML-based batch builds) — buildx bake
# docker-bake.hcl
target "default" {
context = "."
output = ["type=registry"]
}
# Run it
docker buildx bake -f docker-bake.hcl
docker buildx bake --no-cache --push # rebuild without cache + push all targetsCompose: multi-service orchestration
Starting services — docker compose up / down
docker compose up -d # detached mode (default)
docker compose down -v # stop, remove containers + named volumes
docker compose --profile dev --profile test up # activate only matching profiles
docker compose up --build # rebuild images before starting
docker compose up --force-recreate # recreate even if config unchanged
# Scale & manage services
docker compose up --scale web=3 # scale a service
docker compose ps # list running servicesKey options
| Option | Use case |
--dry-run | Preview commands without executing |
--no-build | Skip image building |
--remove-orphans | Remove containers not in compose file |
--abort-on-container-exit | Stop all if one exits |
--exit-code-from=web | Return web service exit code on failure |
Compose service configuration patterns
# docker-compose.yml example
services:
web:
image: myapp:latest
restart: unless-stopped # restart policy
ports:
- "8080:80"
environment:
- NODE_ENV=production
env_file: .env # external env file
depends_on:
db:
condition: service_healthy # wait for healthcheck
volumes:
- ./src:/app/src:ro # bind mount
- data:/data # named volume
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
restart_policy:
condition: on-failure
max_attempts: 3
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- frontend
db:
image: postgres:16
restart: always
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password # secret file mount
secrets:
- db_password
configs:
- postgresql.conf
networks:
- frontend
volumes:
data:
pgdata:
secrets:
db_password:
file: ./secrets/db_password.txt
configs:
postgresql.conf:
file: ./configs/postgresql.conf
networks:
frontend:
driver: bridgeNetwork & Volume Management
# Networks
docker network create --driver bridge mynet
docker network ls # list networks
docker network inspect --format='{{json .IPAM.Config}}' mynet # subnet info
docker network connect/disconnect <container> <network> # hot-swap networking
# Volumes (persistent data)
docker volume create mydata # named volumes
docker volume ls -f 'dangling=true' # unused volumes
docker volume prune -a # remove all unusedSystem Commands: info / events / df
docker info # daemon config, storage driver, runtime details
docker events --filter 'type=container' # real-time container events (for monitoring)
docker system df # disk usage by images/containers/volumes
docker system prune -a --volumes # aggressive cleanup: remove unused + volumesDocker Exec & File Transfer
docker exec -it <container> sh # interactive shell
docker exec -it -u root <container> sh # run as root
docker exec -it -w /app <container> bash -c "ls -la" # one-shot command in working dir
docker exec -d <container> <cmd> # detached exec (returns immediately)
docker exec -e MYVAR=value <container> cmd # pass env vars to exec
docker exec -i -t --privileged <container> cmd # privileged exec
# Copy files to/from containers
docker cp <container>:/path/to/file ./local_file # extract from container
docker cp ./local_file <container>:/path/to/dest # inject into container
docker cp -a <container>:/path ./local_dir # preserve uid/gid info
docker cp -L ./src <container>:/dest # follow symlinksDocker Secrets & Configs
Note:
docker secretanddocker configare Swarm cluster management commands — run on a manager node.
# Secrets (sensitive data: passwords, keys, certs)
docker secret create mydb-pass ./password.txt # create from file
docker secret ls # list secrets
docker secret inspect mydb-pass # inspect details
docker secret rm mydb-pass # remove secret
# Configs (non-sensitive configuration: nginx.conf, app.yaml)
docker config create nginx-conf ./nginx.conf # create from file
docker config ls # list configs
docker config inspect nginx-conf # inspect details
docker config rm nginx-conf # remove config
# In docker-compose.yml:
services:
app:
secrets:
- mydb-pass
source: mydb-pass # map to container secret
configs:
- nginx-confCommon Patterns & Gotchas
--detach-keys— Override Ctrl+C escape sequence to avoid conflicting with your editor (e.g.,Ctrl+q q)- Named vs anonymous volumes — Named (
-v data:/data) persist after rm; anonymous do not unless you use--rm docker exec -druns detached and returns immediately, useful for background tasks in a running container- Build cache sharing via
buildx bakeis more efficient than repeated single-image builds - Profile-based compose (
--profile) enables environment-specific service activation (dev/test/prod) - Device I/O limits (
--device-read-bps,--device-write-iops) require host device access and may not work on all configurations (e.g., containers without direct device access)
Troubleshooting
Container OOM Killed
docker inspect --format='{{.State.OOMKilled}}' <container> # check if OOM
docker logs --tail 50 <container> # check for OOM messages
# Fix: increase --memory limit or optimize container memory usagePort Already in Use
ss -tlnp | grep :80 # find what's using the port
# Fix: use a different host port (-p 8080:80) or stop the conflicting serviceBind Mount Permission Denied
ls -la /host/path # check host permissions
docker inspect --format='{{.Mounts}}' <container> # verify mount config
# Fix: chown/chmod host path, or use :ro and verify user contextImage Pull Rate Limited
Error: toomanyrequests: You have reached your pull rate limit.# Fix: authenticate with Docker Hub
docker login # or use a private registry
# Free accounts: 200 pulls/6h; Anonymous: 100 pulls/6hContainer Won't Start — Check Why
docker ps -a | grep <name> # see exit code
docker inspect --format='{{.State.ExitCode}}' <container> # exit code
docker logs <container> # container logs
docker events --filter 'container=<name>' --since 10m # recent eventsCommon Exit Codes
| Code | Meaning |
| 1 | Application error |
| 125 | Docker daemon error |
| 126 | Command not executable |
| 127 | Command not found |
| 134 | Abnormal termination (e.g., SIGABRT) |
| 137 | SIGKILL (often OOM kill) |
| 139 | Segmentation fault |
| 143 | SIGTERM (graceful shutdown) |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

