Files
nexus/wiki/concepts/APT-仓库配置.md
2026-04-22 04:03:04 +08:00

45 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "APT 仓库配置"
tags: [apt, ubuntu, repository]
date: 2026-04-22
---
# APT 仓库配置
## Definition
APT (Advanced Package Tool) 仓库是 Ubuntu/Debian 系统的软件包来源,通过配置文件指定软件包的下载位置和签名验证方式。
## Docker 官方仓库配置流程
1. 安装 HTTPS 传输依赖:`sudo apt-get install ca-certificates curl`
2. 创建密钥目录:`sudo install -m 0755 -d /etc/apt/keyrings`
3. 下载并导入 GPG 密钥
4. 添加仓库源文件到 `/etc/apt/sources.list.d/`
## 配置文件位置
| 路径 | 作用 |
|------|------|
| `/etc/apt/sources.list` | 系统主仓库配置 |
| `/etc/apt/sources.list.d/*.list` | 第三方仓库配置 |
| `/etc/apt/keyrings/` | GPG 密钥存储目录 |
## Docker 仓库源文件示例
```bash
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```
## Key Concepts
- **架构变量** `$(dpkg --print-architecture)`:自动适配 amd64/arm64 等架构
- **版本代号** `$VERSION_CODENAME`Ubuntu 版本代号(如 jammy、noble
- **签名验证** `signed-by`:指定 GPG 密钥路径
## Related Sources
- [[如何在ubuntu-server安装-docker-docker-compose]] — Docker APT 仓库完整配置流程
## Related Concepts
- [[GPG 密钥验证]] — apt 包签名验证机制
- [[Docker Engine]] — 通过 APT 仓库安装
- [[Ubuntu Server]] — APT 包管理器的宿主系统