MCPInstall

image-management

Docker 镜像管理

Installs
66
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/chaterm/terminal-skills --skill image-management
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads image-management automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Docker 镜像管理

概述

镜像构建、多阶段构建、镜像优化等技能。

镜像操作

查看镜像

# 列出镜像
docker images
docker images -a                    # 包含中间层
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"

# 镜像详情
docker inspect image_name
docker history image_name           # 构建历史

# 搜索镜像
docker search nginx

拉取与推送

# 拉取镜像
docker pull nginx
docker pull nginx:1.20
docker pull registry.example.com/myapp:latest

# 推送镜像
docker push myrepo/myimage:tag

# 登录仓库
docker login
docker login registry.example.com
docker logout

镜像标签

# 添加标签
docker tag source_image:tag target_image:tag
docker tag myapp:latest myrepo/myapp:v1.0

# 删除镜像
docker rmi image_name
docker rmi -f image_name            # 强制删除
docker image prune                  # 删除悬空镜像
docker image prune -a               # 删除未使用镜像

导入导出

# 导出镜像
docker save -o myimage.tar myimage:tag
docker save myimage:tag | gzip > myimage.tar.gz

# 导入镜像
docker load -i myimage.tar
docker load < myimage.tar.gz

镜像构建

基础构建

# 构建镜像
docker build -t myimage:tag .
docker build -t myimage:tag -f Dockerfile.prod .

# 指定构建参数
docker build --build-arg VERSION=1.0 -t myimage:tag .

# 不使用缓存
docker build --no-cache -t myimage:tag .

# 指定目标阶段
docker build --target builder -t myimage:builder .

Dockerfile 基础

# 基础镜像
FROM node:18-alpine

# 元数据
LABEL maintainer="your@email.com"
LABEL version="1.0"

# 设置工作目录
WORKDIR /app

# 复制文件
COPY package*.json ./
COPY . .

# 运行命令
RUN npm install

# 环境变量
ENV NODE_ENV=production
ENV PORT=3000

# 暴露端口
EXPOSE 3000

# 启动命令
CMD ["node", "app.js"]

多阶段构建

# 构建阶段
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# 生产阶段
FROM node:18-alpine AS production
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/main.js"]

Go 应用多阶段构建

# 构建阶段
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o main .

# 生产阶段
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/main .
EXPOSE 8080
CMD ["./main"]

镜像优化

减小镜像体积

# 1. 使用精简基础镜像
FROM alpine:latest
FROM node:18-alpine
FROM python:3.11-slim

# 2. 合并 RUN 命令
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        package1 \
        package2 && \
    rm -rf /var/lib/apt/lists/*

# 3. 使用 .dockerignore
# .dockerignore 文件
node_modules
.git
*.md
Dockerfile
.dockerignore

# 4. 多阶段构建只复制必要文件
COPY --from=builder /app/dist ./dist

构建缓存优化

# 先复制依赖文件,利用缓存
COPY package*.json ./
RUN npm ci

# 再复制源代码
COPY . .
RUN npm run build

安全最佳实践

# 1. 使用非 root 用户
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

# 2. 固定版本
FROM node:18.17.0-alpine3.18

# 3. 扫描漏洞
# docker scan myimage:tag

# 4. 最小权限
RUN chmod 500 /app/main

私有仓库

搭建私有仓库

# 运行 Registry
docker run -d -p 5000:5000 --name registry registry:2

# 推送到私有仓库
docker tag myimage:tag localhost:5000/myimage:tag
docker push localhost:5000/myimage:tag

# 拉取
docker pull localhost:5000/myimage:tag

配置认证

# 创建密码文件
htpasswd -Bc /auth/htpasswd admin

# 运行带认证的 Registry
docker run -d -p 5000:5000 \
  -v /auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \
  registry:2

常见场景

场景 1:分析镜像层

# 查看镜像层
docker history myimage:tag --no-trunc

# 使用 dive 分析
docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
  wagoodman/dive:latest myimage:tag

场景 2:清理磁盘空间

# 查看磁盘使用
docker system df
docker system df -v

# 清理未使用资源
docker system prune              # 清理悬空资源
docker system prune -a           # 清理所有未使用资源
docker system prune --volumes    # 包括卷

场景 3:镜像漏洞扫描

# Docker Scout
docker scout cves myimage:tag

# Trivy
docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  aquasec/trivy image myimage:tag

故障排查

问题排查方法
构建失败检查 Dockerfile 语法、网络
镜像过大使用多阶段构建、精简基础镜像
拉取失败检查网络、认证、镜像名
缓存失效检查 COPY 顺序、文件变更

FAQ

What does the image-management skill do?

Docker 镜像管理

How do I install image-management?

Run npx skills add https://github.com/chaterm/terminal-skills --skill image-management in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/image-management/ (personal) or .claude/skills/image-management/ (project).

Which AI agents can use image-management?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is image-management safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains image-management?

It is published by chaterm in chaterm/terminal-skills. It has 66 recorded installs.

More from chaterm/terminal-skills

View all →

cron

chaterm/terminal-skills

定时任务管理

1.3K installs

system-admin

chaterm/terminal-skills

Linux system administration and monitoring

DevOps & Cloud561 installs

systemd

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

253 installs

network-tools

chaterm/terminal-skills

Open the skill to read its SKILL.md instructions.

217 installs

vpn

chaterm/terminal-skills

VPN 配置与管理

193 installs

ssh

chaterm/terminal-skills

SSH 管理与安全

147 installs

Popular media & creative skills

View category →

hyperframes

heygen-com/hyperframes

Read first to make, edit, animate or render any video with HyperFrames (HTML rendered to video), including launch films, explainers, music videos, charts, maps, vertical clips, title cards, captions and overlays. Holds the render contract, the work loop and what each kind of video needs.

Media & Creative1.2M installs

media-use

heygen-com/hyperframes

Get or make any media for a HyperFrames video - music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks - with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull, or should be stylized or hidden.

Media & Creative1.1M installs

hyperframes-registry

heygen-com/hyperframes

About 450 ready-made HyperFrames blocks and components installed as editable source - transitions, overlays, titles, kinetic type, captions, charts, map overlays, 3D, camera moves. Use it before hand-building any named visual (CRT scanlines, glitch, film grain, a chart); also for hyperframes add and catalog.

Media & Creative1M installs

hyperframes-creative

heygen-com/hyperframes

Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use hyperframes-animation.

Media & Creative916.5K installs

ai-video-generation

101-skills/superpowers

Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse

Media & Creative881.5K installs

ai-image-generation

101-skills/superpowers

Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FLUX.2 Klein LoRA, Gemini 3 Pro Image, Grok Imagine, Seedream 4.5, Reve, ImagineArt. Capabilities: text-to-image, image-to-image, inpainting, LoRA, image editing, upscaling, text rendering. Use for: AI art, product mockups, concept art, social media graphics, marketing visuals, illustrations. Triggers: flux, image generation, ai image, text to image, stable diffusion, generate image, ai art, midjourney alternative, dall-e alternative, text2img, t2i, image generator, ai picture, create image with ai, generative ai, ai illustration, grok image, gemini image, gpt image, openai image, chatgpt image

Media & Creative880.3K installs