Containerization logo

Containerization

Community
zhaoxuya520
containerization

Docker 多阶段构建、镜像优化、Distroless 基础镜像、安全扫描(Trivy)、Docker Compose 编排。适用于应用容器化、镜像瘦身、供应链安全加固场景。

Overview

Publisherzhaoxuya520
RepositoryAI-Fullstack-Delivery-Workflow
Skill namecontainerization
Stars
56
Forks
18
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zhaoxuya520 on GitHub. Read the source before you install it.

Installation

Install the Containerization AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow/tree/master/workflows/devops-engineer/skills/containerization
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow.git /tmp/AI-Fullstack-Delivery-Workflow
mkdir -p .claude/skills
cp -r /tmp/AI-Fullstack-Delivery-Workflow/workflows/devops-engineer/skills/containerization .claude/skills/containerization
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Containerization in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Containerization on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Containerization is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

容器化(Containerization)

参考来源:Docker 官方文档、Google Distroless 项目、Trivy 文档、CNCF 容器安全白皮书、Chainguard Images。

适用场景

  • 应用首次容器化(从裸机 / VM 迁移)
  • 镜像体积优化(>500MB 需瘦身)
  • 多阶段构建设计
  • 安全基线加固(CVE 扫描、非 root 运行)
  • 本地开发环境编排(Docker Compose)
  • CI 中的镜像构建与推送
  • 多架构镜像(linux/amd64 + linux/arm64)

核心原则

text
1. 最小化攻击面
   使用 Distroless / Alpine / scratch
   不安装调试工具到生产镜像

2. 多阶段构建
   编译阶段 → 运行阶段
   只复制产物,不复制源码

3. 层缓存优先
   依赖安装在前,源码复制在后
   利用 BuildKit 缓存挂载

4. 非 root 运行
   USER 指令指定非特权用户
   文件权限最小化

5. 可复现构建
   锁定基础镜像 digest
   锁定依赖版本

6. 扫描前置
   CI 中构建后立即扫描
   阻断 HIGH/CRITICAL 漏洞

7. 标签规范
   语义化版本 + git SHA
   不依赖 :latest

工作流程

text
1. 分析应用依赖
   - 运行时需要哪些系统库
   - 编译时需要哪些工具链
   - 区分 devDependencies vs dependencies

2. 选择基础镜像
   - 编译阶段:官方 SDK 镜像(node:20, golang:1.22, python:3.12)
   - 运行阶段:distroless / alpine / scratch
   - 锁定 digest(sha256:xxx)

3. 编写多阶段 Dockerfile
   - Stage 1: 安装依赖
   - Stage 2: 编译 / 构建
   - Stage 3: 仅复制产物到最小运行时

4. 优化层缓存
   - COPY package.json → RUN npm ci → COPY src/
   - 使用 --mount=type=cache 加速

5. 安全加固
   - 添加 .dockerignore
   - USER nonroot
   - HEALTHCHECK 指令
   - 不暴露不必要端口

6. 本地验证
   - docker build --target=production
   - docker compose up(集成测试)
   - dive 分析层

7. 安全扫描
   - trivy image <image>:<tag>
   - 阻断 HIGH/CRITICAL
   - 生成 SBOM

8. 推送与签名
   - docker push → registry
   - cosign sign(可选)
   - 记录 digest

镜像优化策略

策略效果适用场景
多阶段构建减少 50-90%所有项目
Distroless减少 70%+Go / Java / Node
Alpine 基础减少 60%需要 shell 调试
.dockerignore减少构建上下文所有项目
--mount=type=cache加速构建依赖多的项目
合并 RUN 指令减少层数多 apt-get 场景
scratch最小(<10MB)静态编译 Go

Docker Compose 编排

yaml
# docker-compose.yml 结构
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgres://db:5432/app
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 10s
      timeout: 5s
      retries: 3

  db:
    image: postgres:16-alpine
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]

volumes:
  pgdata:

质量自检

text
□ 使用多阶段构建
□ 运行阶段基于 Distroless / Alpine / scratch
□ 基础镜像锁定 digest 或具体版本
□ 非 root 用户运行
□ .dockerignore 排除无关文件
□ 依赖安装层在源码复制层之前(缓存友好)
□ 无 secrets 硬编码在镜像中
□ HEALTHCHECK 已配置
□ Trivy 扫描无 HIGH/CRITICAL
□ 镜像大小合理(<200MB 应用层)
□ 多架构构建(如需)
□ docker compose 可一键启动本地环境
□ 标签使用语义化版本 + SHA

常见坑

  1. :latest 标签——不可复现,生产回滚困难
  2. 单阶段构建——镜像含编译工具链,体积 1GB+
  3. root 运行——容器逃逸后直接 root 权限
  4. COPY . .——把 .git / node_modules / .env 打入镜像
  5. 不锁定基础镜像——上游更新导致构建失败
  6. RUN apt-get 不清理——每层残留缓存
  7. secrets 写入 ENV——docker inspect 可见
  8. 不用 .dockerignore——构建上下文 GB 级
  9. HEALTHCHECK 缺失——编排器无法判断就绪
  10. 层顺序错误——改一行代码重装所有依赖
  11. 不扫描就推送——带 CVE 上生产
  12. compose 硬编码端口——团队冲突

配套模板

  • templates/dockerfile-template.md — 多阶段 Dockerfile + .dockerignore + Compose 模板

与其他 skill 的协作

text
上游:
  backend-engineer → 应用代码 + 依赖清单
  frontend-engineer → 静态产物构建

下游:
  ci-cd-pipeline → 镜像构建阶段
  kubernetes-orchestration → 镜像部署
  secrets-config → 运行时 secrets 注入
  monitoring-alerting → 健康检查端点

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Containerization AI skill do?

Docker 多阶段构建、镜像优化、Distroless 基础镜像、安全扫描(Trivy)、Docker Compose 编排。适用于应用容器化、镜像瘦身、供应链安全加固场景。

Why use Containerization on TypingMind?

Because you install it once and use it with any model. Containerization is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Containerization in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zhaoxuya520/AI-Fullstack-Delivery-Workflow/tree/master/workflows/devops-engineer/skills/containerization. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Containerization?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Containerization?

As many as you like. As long as a model supports skills, you can use Containerization with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Containerization AI skill free?

It is published on GitHub by zhaoxuya520. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇