pespringer

Docker Essentials 1.0.0

运维安全v1.0.0
作者:pespringer更新于 2026-05-11docker-essentials-1-0-0@clawhub_pespringer/docker-essentials-1-0-0
服务器运维DevOps#Docker#Debugging

据 AlphaMoat 统计,截至 2026-09,Docker Essentials 1.0.0 累计下载 2,863 次、获 1 个星标,在全部 5,078 个 AI 技能中排名第 3,825 位,在「运维安全」分类(264 个)中排名第 243 位。

累计安装
106
累计下载
2,863
星标
1
全站排名
#3,825
全站前 76% · 「运维安全」前 93%
平台累计安装累计下载星标评论
ClawHub ↗812,5141-
SkillHub ↗1062,8631—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

主文汇总了容器生命周期、日志与检查、镜像构建和管理、Compose、网络、卷及系统清理等常用命令。执行 prune、强制删除或卷移除前,应先核对目标资源和环境;清理操作可能删除本地容器、镜像或持久化数据。

资料发布于 2026-10-29

可以用来做什么

  • 查找容器和镜像管理命令
  • 整理 Compose、网络和卷的操作步骤
  • 检查清理命令的影响范围

什么时候用

  • 需要查阅 Docker CLI 的常见操作时
  • 已确认目标容器、镜像或服务时
  • 计划清理数据前可以先检查影响范围时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

解释如何检查容器状态,但不要执行命令
总结停止容器与删除容器的区别
列出运行清理命令前需要核实的资源和数据

月度数据趋势

累计下载2,863
1,6302,2922,9542026-03 · 累计下载 1,7212026-05 · 累计下载 2,0302026-06 · 累计下载 2,1412026-07 · 累计下载 2,3442026-08 · 累计下载 2,5062026-09 · 累计下载 2,86326-0326-09
星标1
0122026-03 · 星标 12026-05 · 星标 12026-06 · 星标 12026-07 · 星标 12026-08 · 星标 12026-09 · 星标 126-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。 该技能有同名的其他版本,调整前的数据归属当前下载量最大的这一个。

月份累计下载环比星标
2026-092,863—1
2026-082,506+6.9%1
2026-072,344+9.5%1
2026-062,141+5.5%1
2026-052,030—1
2026-031,721—1

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

6.1 KB · ClawHub v1.0.0
---
name: docker-essentials
description: Essential Docker commands and workflows for container management, image operations, and debugging.
homepage: https://docs.docker.com/
metadata: {"clawdbot":{"emoji":"🐳","requires":{"bins":["docker"]}}}
---

# Docker Essentials

Essential Docker commands for container and image management.
展开全部(共 350 行)

## Container Lifecycle

### Running containers
```bash
# Run container from image
docker run nginx

# Run in background (detached)
docker run -d nginx

# Run with name
docker run --name my-nginx -d nginx

# Run with port mapping
docker run -p 8080:80 -d nginx

# Run with environment variables
docker run -e MY_VAR=value -d app

# Run with volume mount
docker run -v /host/path:/container/path -d app

# Run with auto-remove on exit
docker run --rm alpine echo "Hello"

# Interactive terminal
docker run -it ubuntu bash
```

### Managing containers
```bash
# List running containers
docker ps

# List all containers (including stopped)
docker ps -a

# Stop container
docker stop container_name

# Start stopped container
docker start container_name

# Restart container
docker restart container_name

# Remove container
docker rm container_name

# Force remove running container
docker rm -f container_name

# Remove all stopped containers
docker container prune
```

## Container Inspection & Debugging

### Viewing logs
```bash
# Show logs
docker logs container_name

# Follow logs (like tail -f)
docker logs -f container_name

# Last 100 lines
docker logs --tail 100 container_name

# Logs with timestamps
docker logs -t container_name
```

### Executing commands
```bash
# Execute command in running container
docker exec container_name ls -la

# Interactive shell
docker exec -it container_name bash

# Execute as specific user
docker exec -u root -it container_name bash

# Execute with environment variable
docker exec -e VAR=value container_name env
```

### Inspection
```bash
# Inspect container details
docker inspect container_name

# Get specific field (JSON path)
docker inspect -f '{{.NetworkSettings.IPAddress}}' container_name

# View container stats
docker stats

# View specific container stats
docker stats container_name

# View processes in container
docker top container_name
```

## Image Management

### Building images
```bash
# Build from Dockerfile
docker build -t myapp:1.0 .

# Build with custom Dockerfile
docker build -f Dockerfile.dev -t myapp:dev .

# Build with build args
docker build --build-arg VERSION=1.0 -t myapp .

# Build without cache
docker build --no-cache -t myapp .
```

### Managing images
```bash
# List images
docker images

# Pull image from registry
docker pull nginx:latest

# Tag image
docker tag myapp:1.0 myapp:latest

# Push to registry
docker push myrepo/myapp:1.0

# Remove image
docker rmi image_name

# Remove unused images
docker image prune

# Remove all unused images
docker image prune -a
```

## Docker Compose

### Basic operations
```bash
# Start services
docker-compose up

# Start in background
docker-compose up -d

# Stop services
docker-compose down

# Stop and remove volumes
docker-compose down -v

# View logs
docker-compose logs

# Follow logs for specific service
docker-compose logs -f web

# Scale service
docker-compose up -d --scale web=3
```

### Service management
```bash
# List services
docker-compose ps

# Execute command in service
docker-compose exec web bash

# Restart service
docker-compose restart web

# Rebuild service
docker-compose build web

# Rebuild and restart
docker-compose up -d --build
```

## Networking

```bash
# List networks
docker network ls

# Create network
docker network create mynetwork

# Connect container to network
docker network connect mynetwork container_name

# Disconnect from network
docker network disconnect mynetwork container_name

# Inspect network
docker network inspect mynetwork

# Remove network
docker network rm mynetwork
```

## Volumes

```bash
# List volumes
docker volume ls

# Create volume
docker volume create myvolume

# Inspect volume
docker volume inspect myvolume

# Remove volume
docker volume rm myvolume

# Remove unused volumes
docker volume prune

# Run with volume
docker run -v myvolume:/data -d app
```

## System Management

```bash
# View disk usage
docker system df

# Clean up everything unused
docker system prune

# Clean up including unused images
docker system prune -a

# Clean up including volumes
docker system prune --volumes

# Show Docker info
docker info

# Show Docker version
docker version
```

## Common Workflows

**Development container:**
```bash
docker run -it --rm \
  -v $(pwd):/app \
  -w /app \
  -p 3000:3000 \
  node:18 \
  npm run dev
```

**Database container:**
```bash
docker run -d \
  --name postgres \
  -e POSTGRES_PASSWORD=secret \
  -e POSTGRES_DB=mydb \
  -v postgres-data:/var/lib/postgresql/data \
  -p 5432:5432 \
  postgres:15
```

**Quick debugging:**
```bash
# Shell into running container
docker exec -it container_name sh

# Copy file from container
docker cp container_name:/path/to/file ./local/path

# Copy file to container
docker cp ./local/file container_name:/path/in/container
```

**Multi-stage build:**
```dockerfile
# Dockerfile
FROM node:18 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
```

## Useful Flags

**`docker run` flags:**
- `-d`: Detached mode (background)
- `-it`: Interactive terminal
- `-p`: Port mapping (host:container)
- `-v`: Volume mount
- `-e`: Environment variable
- `--name`: Container name
- `--rm`: Auto-remove on exit
- `--network`: Connect to network

**`docker exec` flags:**
- `-it`: Interactive terminal
- `-u`: User
- `-w`: Working directory

## Tips

- Use `.dockerignore` to exclude files from build context
- Combine `RUN` commands in Dockerfile to reduce layers
- Use multi-stage builds to reduce image size
- Always tag your images with versions
- Use `--rm` for one-off containers
- Use `docker-compose` for multi-container apps
- Clean up regularly with `docker system prune`

## Documentation

Official docs: https://docs.docker.com/
Dockerfile reference: https://docs.docker.com/engine/reference/builder/
Compose file reference: https://docs.docker.com/compose/compose-file/

「运维安全」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。