
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Alpine Linux的官方Docker镜像。该镜像仅5MB大小,且拥有比其他基于BusyBox的镜像更丰富的包仓库。
如今的Docker镜像通常体积过大,超出实际需求。虽然有多种方法可以减小镜像大小,但Docker用户仍倾向于为大多数项目选择ubuntu作为基础镜像。与ubuntu及其他基础镜像相比,Alpine的体积优势极为显著:
textREPOSITORY TAG IMAGE ID CREATED SIZE alpine latest 961769676411 4周前 5.58MB ubuntu latest 2ca708c1c9cc 2天前 64.2MB debian latest c2c03a296d23 9天前 114MB centos latest 67fa590cfc1c 4周前 202MB
有些镜像如progrium/busybox能提供接近最小化的容器和包系统,但这些特定的BusyBox构建依赖OpenWRT包索引,往往功能不足且未针对通用日常应用进行优化。Alpine Linux拥有更丰富且更新及时的https://pkgs.alpinelinux.org%EF%BC%9A
bash$ docker run progrium/busybox opkg-install nodejs Unknown package 'nodejs'. Collected errors: * opkg_install_cmd: Cannot install package nodejs. $ docker run alpine apk add --no-cache nodejs fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz (1/7) Installing ca-certificates (20190108-r0) (2/7) Installing c-ares (1.15.0-r0) (3/7) Installing libgcc (8.3.0-r0) (4/7) Installing http-parser (2.8.1-r0) (5/7) Installing libstdc++ (8.3.0-r0) (6/7) Installing libuv (1.23.2-r0) (7/7) Installing nodejs (10.14.2-r0) Executing busybox-1.29.3-r10.trigger Executing ca-certificates-20190108-r0.trigger OK: 31 MiB in 21 packages
这使得Alpine Linux成为工具类应用和生产环境应用的理想基础镜像。https://www.alpinelinux.org/about/%EF%BC%8C%E4%BD%A0%E4%BC%9A%E5%8F%91%E7%8E%B0%E5%AE%83%E7%9A%84%E7%90%86%E5%BF%B5%E4%B8%8EDocker%E9%95%9C%E5%83%8F%E7%9A%84%E9%9C%80%E6%B1%82%E9%AB%98%E5%BA%A6%E5%A5%91%E5%90%88%E3%80%82
注意:上述所有示例输出的最后生成/更新日期为2019年5月3日。
停止这样做:
dockerfileFROM docker.xuanyuan.run/ubuntu:22.04 RUN apt-get update -q \ && DEBIAN_FRONTEND=noninteractive apt-get install -qy mysql-client \ && apt-get clean \ && rm -rf /var/lib/apt ENTRYPOINT ["mysql"]
这需要28秒构建,生成169 MB的镜像。
开始这样做:
dockerfileFROM docker.xuanyuan.run/alpine:3.16 RUN apk add --no-cache mysql-client ENTRYPOINT ["mysql"]
仅需4秒构建,结果是41 MB的镜像!
运行命令:
bashdocker run docker.xuanyuan.run/alpine:latest echo "Hello from Alpine!"
交互式shell:
bashdocker run -it docker.xuanyuan.run/alpine:latest /bin/sh
安装软件包:
bashdocker run docker.xuanyuan.run/alpine:latest apk add --no-cache curl
dockerfileFROM docker.xuanyuan.run/alpine:3.22 RUN apk add --no-cache nginx EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
💡 有关生产环境示例、最佳实践和高级用法,请参见docs/usage.md
关键差异:
| 方面 | Ubuntu/Debian | Alpine |
|---|---|---|
| 包管理器 | apt-get | apk |
| C库 | glibc | musl libc |
| 默认shell | bash | sh (BusyBox ash) |
| 初始化系统 | systemd | OpenRC |
常见包映射:
| Ubuntu/Debian | Alpine |
|---|---|
build-essential | build-base |
python3-pip | py3-pip |
ca-certificates | ca-certificates |
快速转换:
dockerfile# 之前(Ubuntu) FROM docker.xuanyuan.run/ubuntu:22.04 RUN apt-get update && apt-get install -y python3 python3-pip # 之后(Alpine) FROM docker.xuanyuan.run/alpine:3.22 RUN apk add --no-cache python3 py3-pip
📚 有关详细迁移指南和故障排除,请参见docs/usage.md和docs/caveats.md
此仓库中的所有镜像均采用企业级安全特性构建:
镜像使用特定于 registry 的最佳实践进行签名和证明:
对于GHCR (ghcr.io):GitHub原生证明
对于DockerHub (docker.io):Sigstore Cosign签名
验证GHCR镜像(推荐)
bash# 安装GitHub CLI(如果尚未安装) # macOS: brew install gh # Linux: 参见 https://github.com/cli/cli#installation # 使用GitHub证明验证GHCR镜像 gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 --owner broadsage # 查看详细的来源和SBOM gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 \ --owner broadsage \ --format json | jq
验证DockerHub镜像
bash# 安装cosign(如果尚未安装) # macOS: brew install cosign # Linux: 参见 https://docs.sigstore.dev/cosign/installation/ # 验证DockerHub镜像签名 cosign verify \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22
每个镜像均包含SPDX格式的软件物料清单,提供所有包和依赖项的完整透明度。
查看GHCR镜像的SBOM
bash# GHCR:SBOM包含在GitHub证明中 gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 \ --owner broadsage \ --format json | jq '.verificationResult.statement.predicate'
查看DockerHub镜像的SBOM
bash# DockerHub:SBOM作为Cosign证明附加 cosign verify-attestation \ --type spdxjson \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 | jq -r '.payload' | base64 -d | jq
所有镜像均包含SLSA v1.0构建来源证明,提供有关镜像构建方式的可验证信息,包括:
验证GHCR镜像的构建来源
bash# GHCR:内置GitHub证明(推荐) gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 --owner broadsage # 以JSON格式查看详细来源 gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 \ --owner broadsage \ --format json | jq '.verificationResult.statement.predicate'
验证DockerHub镜像的构建来源
bash# 验证来源证明签名 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 # 提取并查看来源详情 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 \ | jq -r '.payload' | base64 -d | jq '.predicate' # 查看特定来源字段 # 构建器信息 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 \ | jq -r '.payload' | base64 -d | jq '.predicate.runDetails.builder' # 源代码仓库和提交 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 \ | jq -r '.payload' | base64 -d | jq '.predicate.buildDefinition.resolvedDependencies' # 完整构建工作流信息 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 \ | jq -r '.payload' | base64 -d | jq '.predicate.buildDefinition.externalParameters'
一次性验证所有证明
bash# GHCR:验证所有证明(SBOM + 来源) gh attestation verify oci://ghcr.io/broadsage/alpine:3.22 \ --owner broadsage # DockerHub:列出所有证明 cosign tree docker.io/broadsage/alpine:3.22 # DockerHub:验证镜像签名 cosign verify \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 # DockerHub:验证SBOM证明 cosign verify-attestation \ --type spdxjson \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22 # DockerHub:验证来源证明 cosign verify-attestation \ --type https://slsa.dev/provenance/v1 \ --certificate-identity-regexp="https://github.com/broadsage/docker-alpine" \ --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ docker.io/broadsage/alpine:3.22
验证故障排除
如果验证失败,请确保:
Cosign已更新(v2.0+):
bashcosign version # 应显示v2.0.0或更高版本
镜像标签存在:
bashdocker pull docker.xuanyuan.run/broadsage/alpine:3.22
使用完整镜像引用:
bash# ✅ 正确 docker.io/broadsage/alpine:3.22 # ❌ 不正确(缺少 registry) broadsage/alpine:3.22
网络连接到Rekor透明度日志:
bashcurl -s https://rekor.sigstore.dev/api/v1/log | jq
所有镜像均使用https://snyk.io/product/container-vulnerability-management/%E8%BF%9B%E8%A1%8C%E5%AE%89%E5%85%A8%E6%BC%8F%E6%B4%9E%E6%89%AB%E6%8F%8F%EF%BC%8C%E9%87%87%E7%94%A8%E4%BC%81%E4%B8%9A%E7%BA%A7%E6%BC%8F%E6%B4%9E%E6%A3%80%E6%B5%8B%E3%80%82
查看安全发现:
bash# 检查GitHub安全选项卡获取漏洞报告 # https://github.com/broadsage/docker-alpine/security/code-scanning
Snyk扫描提供:
镜像原生支持8种架构:
linux/amd64(x86_64)linux/arm64(aarch64)linux/arm/v7(armv7)linux/arm/v6(armhf)linux/386(x86)linux/ppc64lelinux/s390xlinux/riscv64Docker会自动为你的平台拉取正确的架构版本。
latest - 最新稳定版本(当前为3.22.x)edge - 来自Alpine edge分支的滚动发布3.22, 3.22.2 - 特定版本标签3.21, 3.21.5 - 之前的稳定版本3.20, 3.19 - 更旧的稳定版本所有标签均指向多架构清单。
体积:Alpine镜像比Ubuntu/Debian等效镜像小5-10倍(5MB vs 64MB+)
安全性:更小的***面,最少的软件包和主动安全更新
性能:更快的下载速度,更少的磁盘空间,更快的容器启动
现代化:使用musl libc、BusyBox和现代工具链
镜像会自动重建:
检查镜像来源以查看确切构建时间:
bashdocker inspect alpine:3.22 | jq '.[0].Created'
Alpine使用musl libc而非glibc:
优点:
缺点:
解决方案:使用Alpine软件包(已为musl编译)或从源代码编译。
如果你有glibc编译的二进制文件:
选项1:使用gcompat(添加glibc兼容层):
dockerfileRUN apk add --no-cache gcompat
选项2:使用多
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 broadsage/alpine 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: