跳到主内容
智客 ZICQ

技能库 智客分类:运维与云 container-publish

Container Publish

使用.NET 10 SDK容器出版功能的无多克文件容器化. 覆盖了MSBuild属性,被子化的图像,多arch构建,以及注册发布——都不用写一个多克文件. 当用户想要在没有多克文件的情况下进行容器化,或者提及"多克文件发布","Publish Container","Contain Reposition","Contain Family","Chiseled","District","Contain Plain","SDK Contain","没有多克文件"或"Containerization without Docker"时,加载此技能.

1580 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用.NET 10 SDK容器出版功能的无多克文件容器化. 覆盖了MSBuild属性,被子化的图像,多arch构建,以及注册发布——都不用写一个多克文件. 当用户想要在没有多克文件的情况下进行容器化,或者提及"多克文件发布","Publish Container","Contain Reposition","Contain Family","Chiseled","District","Contain Plain","SDK Contain","没有多克文件"或"Containerization without Docker"时,加载此技能.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Container Publishing (No Dockerfile)、Core Principles、Patterns、Minimal Container Publish、Production-Ready .csproj Configuration、Publishing to a Registry。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Dockerfile-less containerization using the .NET 10 SDK container publishing feature. Covers MSBuild properties, chiseled images, multi-arch builds, and registry publishing — all without writing a Dockerfile. Load this skill when the user wants to containerize without a Dockerfile, or mentions "dotnet publish container", "PublishContainer", "ContainerRepository", "ContainerFamily", "chiseled", "distroless", "container publish", "SDK container", "no Dockerfile", or "containerize without Docker".

Container Publishing (No Dockerfile)Core PrinciplesPatternsMinimal Container PublishProduction-Ready .csproj ConfigurationPublishing to a RegistryGitHub Container RegistryAzure Container RegistryDocker Hub (requires username prefix in repository)Multi-Architecture ImagesMultiple TagsBash — note the quoting for semicolons

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
container-publish
description
Dockerfile-less containerization using the .NET 10 SDK container publishing feature. Covers MSBuild properties, chiseled images, multi-arch builds, and registry publishing — all without writing a Dockerfile. Load this skill when the user wants to containerize without a Dockerfile, or mentions "dotnet publish container", "PublishContainer", "ContainerRepository", "ContainerFamily", "chiseled", "distroless", "container publish", "SDK container", "no Dockerfile", or "containerize without Docker".
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「container-publish」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-e28409eb48c72595-Container-Publish.html
请存为 .cursor/skills/container-publish/SKILL.md 或 .claude/skills/container-publish/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/codewithmukesh/dotnet-claude-kit' --list

npx skills add 'https://github.com/codewithmukesh/dotnet-claude-kit' --skill 'container-publish'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: container-publish description: > Dockerfile-less containerization using the .NET 10 SDK container publishing feature. Covers MSBuild properties, chiseled images, multi-arch builds, and registry publishing — all without writing a Dockerfile. Load this skill when the user wants to containerize without a Dockerfile, or mentions "dotnet publish container", "PublishContainer", "ContainerRepository", "ContainerFamily", "chiseled", "distroless", "container publish", "SDK container", "no Dockerfile", or "containerize without Docker". --- # Container Publishing (No Dockerfile) ## Core Principles 1. **No Dockerfile needed** — The .NET 10 SDK builds OCI-compliant container images directly from `dotnet publish /t:PublishContainer`. No Dockerfile to write or maintain. 2. **Chiseled images for production** — Use `noble-chiseled` base images: no shell, no package manager, 7 Linux components vs 100+. Smallest attack surface. 3. **Non-root by default** — .NET 10 container images run as the `app` user automatically. Never override to root in production. 4. **Configuration in the .csproj** — All container settings are MSBuild properties, versioned with your project. No separate files to drift. ## Patterns ### Minimal Container Publish No project file changes needed. Just publish: ```bash dotnet publish /t:PublishContainer --os linux --arch x64 ``` This creates a container image in your local Docker daemon using the default `aspnet:10.0` base image. ### Production-Ready .csproj Configuration ```xml net10.0 mycompany/myapp-api noble-chiseled ``` ### Publishing to a Registry Authenticate with `docker login` first, then specify the registry: ```bash # GitHub Container Registry docker login ghcr.io dotnet publish /t:PublishContainer --os linux --arch x64 \ -p ContainerRegistry=ghcr.io \ -p ContainerImageTag=1.0.0 # Azure Container Registry az acr login --name myregistry dotnet publish /t:PublishContainer --os linux --arch x64 \ -p ContainerRegistry=myregistry.azurecr.io # Docker Hub (requires username prefix in repository) dotnet publish /t:PublishContainer --os linux --arch x64 \ -p ContainerRegistry=docker.io \ -p ContainerRepository=myuser/myapp ``` ### Multi-Architecture Images Build images for multiple platforms with a single publish: ```xml linux-x64;linux-arm64 linux-x64;linux-arm64 ``` ```bash dotnet publish /t:PublishContainer ``` This produces an OCI Image Index — registries serve the correct architecture automatically. ### Multiple Tags ```bash # Bash — note the quoting for semicolons dotnet publish /t:PublishContainer --os linux --arch x64 \ -p ContainerImageTags='"1.0.0;latest"' ``` Or in the project file: ```xml 1.0.0;latest ``` ### Save as Tarball (No Docker Required) No container runtime needed on the build machine. Useful for CI scanning: ```bash dotnet publish /t:PublishContainer --os linux --arch x64 \ -p ContainerArchiveOutputPath=./images/myapp.tar.gz # Scan with Trivy before pushing trivy image --input ./images/myapp.tar.gz ``` ### Chiseled Image Variants | ContainerFamily | Use Case | Shell | Size | |----------------|----------|-------|------| | *(default)* | General purpose (Debian) | Yes | ~220 MB | | `noble-chiseled` | Production (no shell) | No | ~110 MB | | `noble-chiseled-extra` | Production with localization (ICU) | No | ~120 MB | | `alpine` | Small size, has shell | Yes | ~112 MB | ```xml noble-chiseled noble-chiseled-extra ``` For Native AOT, the SDK auto-selects `chiseled-aot`: ```xml true ``` ### CI/CD with GitHub Actions ```yaml jobs: publish: runs-on: ubuntu-latest permissions: packages: write steps: - uses: actions/checkout@v5 - uses: actions/setup-dotnet@v5 with: dotnet-version: '10.0.x' - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - run: | dotnet publish src/MyApp.Api/MyApp.Api.csproj \ /t:PublishContainer --os linux --arch x64 \ -p ContainerRegistry=ghcr.io \ -p ContainerRepository=${{ github.repository_owner }}/myapp \ -p ContainerImageTag=${{ github.sha }} ``` ## Anti-patterns ### Don't Use the Deprecated Property Names ```xml myapp myapp ``` ### Don't Use PublishProfile=DefaultContainer ```bash # BAD — old approach, inconsistent across project types dotnet publish -p:PublishProfile=DefaultContainer # GOOD — use the MSBuild target directly dotnet publish /t:PublishContainer ``` ### Don't Forget to Target Linux ```bash # BAD on Windows — may produce a Windows container dotnet publish /t:PublishContainer # GOOD — explicitly target Linux dotnet publish /t:PublishContainer --os linux --arch x64 ``` ### Don't Skip Authentication Before Push ```bash # BAD — fails with CONTAINER1013 error dotnet publish /t:PublishContainer -p ContainerRegistry=ghcr.io # GOOD — authenticate first docker login ghcr.io dotnet publish /t:PublishContainer -p ContainerRegistry=ghcr.io ``` ### Don't Use SDK Publishing When You Need OS Packages ```xml myregistry/custom-base:1.0 ``` ## Decision Guide | Scenario | Recommendation | |----------|---------------| | Standard ASP.NET Core API | SDK container publishing with `noble-chiseled` | | Worker service / console app | SDK container publishing (native .NET 10 support) | | Needs native OS packages | Dockerfile (or custom base image + SDK publishing) | | Azure Functions | Dockerfile (not supported by SDK publishing) | | CI without Docker daemon | Tarball output with `ContainerArchiveOutputPath` | | Multi-arch deployment (x64 + arm64) | `ContainerRuntimeIdentifiers` property | | Production image size | `noble-chiseled` (~110 MB) or Native AOT (~10 MB) | | Local development | `dotnet publish /t:PublishContainer --os linux --arch x64` | | Registry push | `ContainerRegistry` + `docker login` |

相关技能

运维与云

Docker Essentials

用于容器管理,图像操作,调试的基本道克命令和工作流程.

运维与云

Find Skills

从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…

运维与云

Azure Diagnostics

Azure上使用AppLens,AzureMonitor,资源健康,安全分型的调试Azure生产问题. 当:调试生产问题,故障解答应用服务,应用服务高CPU,应用服务部署失败,故障解答容器应用,故障解答功能,故障解答AKS,VM RDP,Linux SSH,VM黑屏幕,无法连接到…

运维与云

Azure Prepare

准备 azd 用于部署的Azure项目:为Azure开发者CLI(azd)工作流程生成azure.yaml,基础设施(Bicep/Terraform)和多克文件. 仅当用户明确想要使用 azd 作为部署工具时使用, 或项目已经有一个 azure 。 雅姆尔文件。 不使用: 非az…