Files
nexus/wiki/sources/如何在ubuntu-server安装-docker-docker-compose.md

61 lines
3.4 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: "如何在Ubuntu Server安装 Docker & Docker Compose"
type: source
tags: [docker, ubuntu]
date: 2026-04-14
---
## Source File
- [[raw/Home Office/如何在Ubuntu Server安装 docker & docker compose.md]]
## Summary (用中文描述)
- 核心主题:在 Ubuntu Server 上通过官方 apt 仓库安装 Docker Engine 和 Docker Compose V2 的完整流程
- 问题域:服务器容器化环境搭建
- 方法/机制:五步标准安装流程——卸载旧版 → 配置官方仓库 → 安装引擎 → 验证安装 → 配置非 root 用户
- 结论/价值:推荐从 Docker 官方仓库安装以确保获取最新版本Docker Compose V2 已集成到 docker-compose-plugin使用 `docker compose` 命令
## Key Claims (用中文描述)
- Docker 官方仓库安装能确保获取最新版本的 Docker Engine
- Docker Compose V2 通过 docker-compose-plugin 安装,使用 `docker compose` 命令而非 `docker-compose`
- 将用户加入 docker 用户组后,可无需 sudo 直接运行 Docker 命令
- 必须先安装 ca-certificates 和 curl 才能通过 HTTPS 添加 Docker GPG 密钥和仓库
## Key Quotes
> "It's generally best to install from Docker's official repositories to ensure you have the latest version." — 官方仓库安装的最佳实践理由
> "The `docker-compose-plugin` installs **Docker Compose V2**, which is used via the command `docker compose` instead of `docker-compose`." — V2 版本命令变化说明
> "By default, running Docker commands requires `sudo`. To run Docker without `sudo`, you can add your user to the **`docker` group`." — docker 用户组的作用
## Key Concepts
- [[Docker Engine]]Docker 核心运行时,包含 dockerd 守护进程、CLI 和 containerd 容器运行时
- [[Docker Compose]]:多容器 Docker 应用的定义和运行工具V2 版本集成到 docker CLI`docker compose`
- [[APT 仓库]]Ubuntu/Debian 的软件包管理仓库,通过 /etc/apt/sources.list.d/ 配置
- [[GPG 密钥]]apt 仓库签名验证,确保软件包来源可信
- [[Docker 用户组]]Linux 用户组,允许组成员无需 sudo 直接运行 Docker 命令(存在安全风险)
- [[containerd]]Docker 的容器运行时底层引擎,独立项目
## Key Entities
- [[Docker CE]]Docker Community EditionDocker Engine 的开源版本
- [[docker-ce-cli]]Docker 命令行工具
- [[docker-buildx-plugin]]Docker 扩展插件,支持多平台镜像构建
- [[docker-compose-plugin]]Docker Compose V2 插件,替代独立的 docker-compose 包
- [[containerd.io]]containerd 的 Docker 打包版本
- [[hello-world]]Docker 官方测试镜像,用于验证安装是否成功
## Connections
- [[Docker Engine]] ← installed_by ← [[Docker CE on Ubuntu]]
- [[Docker Compose]] ← extends ← [[Docker Engine]]
- [[APT 仓库]] ← provides ← [[Docker CE]]
- [[GPG 密钥]] ← authenticates ← [[APT 仓库]]
- [[Ubuntu Server]] ← runs_on ← [[Docker Engine]]
- [[Docker 用户组]] ← enables ← [[Docker Engine]] (non-root execution)
- [[containerd]] ← powers ← [[Docker Engine]]
## Contradictions
- 无已知冲突
## Related Sources
- [[用docker安装transmission]] — Docker 部署实战
- [[用docker安装portainer]] — Docker 可视化管理
- [[用docker安装jellyfin]] — Docker 媒体服务
- [[家庭监控方案-prometheus-grafana-node-exporter-cadvisor-blackbox]] — Docker 监控堆栈