Skip to content
Back to skills

Docker

ASecurity

Build, secure, and deploy Docker containers with image optimization, networking, and production-ready patterns.

  • 16 stars
  • 0 votes
  • 1 copy
  • 3 views
  • Added June 7, 2026
devopspythongoshelldockerdebuggingdevopssecurity

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned June 7, 2026

npx -y skills add modbender/skill-library-mcp --skill docker --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-docker/badge)](https://www.skillsdirectory.com/skills/modbender-docker)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Docker (Essentials + Advanced)
slug: docker
version: 1.0.3
homepage: https://clawic.com/skills/docker
description: Build, secure, and deploy Docker containers with image optimization, networking, and production-ready patterns.
changelog: Added essential commands reference and production patterns
metadata: {"clawdbot":{"emoji":"🐳","requires":{"bins":["docker"]},"os":["linux","darwin","win32"]}}
---

## Setup

On first use, read `setup.md` for user preference guidelines.

## When to Use

User needs Docker expertise. Agent handles containers, images, Compose, networking, volumes, and production deployment.

## Architecture

Memory in `~/docker/`. See `memory-template.md` for structure.

```
~/docker/
└── memory.md    # Preferences and context
```

## Quick Reference

| Topic | File |
|-------|------|
| Essential commands | `commands.md` |
| Dockerfile patterns | `images.md` |
| Compose orchestration | `compose.md` |
| Networking & volumes | `infrastructure.md` |
| Security hardening | `security.md` |
| Setup | `setup.md` |
| Memory | `memory-template.md` |

## Core Rules

### 1. Pin Image Versions
- `python:3.11.5-slim` not `python:latest`
- Today's latest differs from tomorrow's β€” breaks immutable builds

### 2. Combine RUN Commands
- `apt-get update && apt-get install -y pkg` in ONE layer
- Separate layers = stale package cache weeks later

### 3. Non-Root by Default
- Add `USER nonroot` in Dockerfile
- Running as root fails security scans and platform policies

### 4. Set Resource Limits
- `-m 512m` on every container
- OOM killer strikes without warning otherwise

### 5. Configure Log Rotation
- Default json-file driver has no size limit
- One chatty container fills disk and crashes host

## Image Traps

- Multi-stage builds: forgotten `--from=builder` copies from wrong stage silently
- COPY before RUN invalidates cache on every file change β€” copy requirements first, install, then copy code
- `ADD` extracts archives automatically β€” use `COPY` unless you need extraction
- Build args visible in image history β€” never use for secrets

## Runtime Traps

- `localhost` inside container is container's localhost β€” bind to `0.0.0.0`
- Port already in use: previous container still stopping β€” wait or force remove
- Exit code 137 = OOM killed, 139 = segfault β€” check with `docker inspect --format='{{.State.ExitCode}}'`
- No shell in distroless images β€” `docker cp` files out or use debug sidecar

## Networking Traps

- Container DNS only works on custom networks β€” default bridge can't resolve names
- Published ports bind to `0.0.0.0` β€” use `127.0.0.1:5432:5432` for local-only
- Zombie connections from killed containers β€” set health checks and restart policies

## Compose Traps

- `depends_on` waits for container start, not service ready β€” use `condition: service_healthy`
- `.env` file in wrong directory silently ignored β€” must be next to docker-compose.yml
- Volume mounts overwrite container files β€” empty host dir = empty container dir
- YAML anchors don't work across files β€” use multiple compose files instead

## Volume Traps

- Anonymous volumes accumulate silently β€” use named volumes
- Bind mounts have permission issues β€” container user must match host user
- `docker system prune` doesn't remove named volumes β€” add `--volumes` flag
- Stopped container data persists until container removed

## Resource Leaks

- Dangling images grow unbounded β€” `docker image prune` regularly
- Build cache grows forever β€” `docker builder prune` reclaims space
- Stopped containers consume disk β€” `docker container prune` or `--rm` on run
- Networks pile up from compose projects β€” `docker network prune`

## Secrets and Security

- ENV and COPY bake secrets into layer history permanently β€” use secrets mount or runtime env
- `--privileged` disables all security β€” almost never needed, find specific capability instead
- Images from unknown registries may be malicious β€” verify sources
- Build args visible in image history β€” don't use for secrets

## Debugging

- Exit code 137 = OOM killed, 139 = segfault β€” check `docker inspect --format='{{.State.ExitCode}}'`
- Container won't start: check logs even for failed containers β€” `docker logs <container>`
- No shell in distroless images β€” `docker cp` files out or use debug sidecar
- Inspect filesystem of dead container β€” `docker cp deadcontainer:/path ./local`

## Related Skills
Install with `clawhub install <slug>` if user confirms:
- `devops` β€” deployment pipelines
- `linux` β€” host system management
- `server` β€” server administration

## Feedback

- If useful: `clawhub star docker`
- Stay updated: `clawhub sync`

Files in this skill

  • SKILL.md4.7 KB
  • commands.md1.4 KB
  • compose.md1.9 KB
  • images.md1.9 KB
  • infrastructure.md1.9 KB
  • memory-template.md659 B
  • security.md2.1 KB
  • setup.md1.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.