|
1 | 1 | # EasyDocker |
2 | 2 |
|
3 | | -Docker 一键安装配置脚本,为不受 Docker 官方安装脚本支持的 Linux 发行版提供安装支持。 |
| 3 | +One-click Docker installation script for Linux distros not covered by the official Docker install script. |
4 | 4 |
|
5 | | -## 快速开始 |
| 5 | +## Quick Start |
6 | 6 |
|
7 | 7 | ```bash |
8 | 8 | bash <(curl -sSL https://raw.githubusercontent.com/web-casa/easydocker/main/docker.sh) |
9 | 9 | ``` |
10 | 10 |
|
11 | | -如果使用 `wget`: |
| 11 | +Or with `wget`: |
12 | 12 |
|
13 | 13 | ```bash |
14 | 14 | bash <(wget -qO- https://raw.githubusercontent.com/web-casa/easydocker/main/docker.sh) |
15 | 15 | ``` |
16 | 16 |
|
17 | | -> 国内服务器如果无法访问 GitHub,可使用 ghproxy 等加速服务,或先手动下载 `docker.sh` 再执行。 |
18 | | -
|
19 | | -## 功能模式 |
20 | | - |
21 | | -脚本运行后会提示选择操作模式: |
| 17 | +## Usage |
22 | 18 |
|
23 | 19 | ``` |
24 | | -请选择操作模式: |
25 | | -1) 一键安装配置(推荐) |
26 | | -2) 修改镜像加速域名 |
| 20 | +bash docker.sh [OPTIONS] |
| 21 | +
|
| 22 | +Options: |
| 23 | + --lang en|zh UI language (default: en) |
| 24 | + --mirror <value> Mirror config: none, public, or a custom domain |
| 25 | + (default: none — uses Docker official registry) |
| 26 | + --mode <value> Operation mode: install or mirror |
| 27 | + -y, --yes Skip interactive confirmations |
| 28 | + -h, --help Show help message |
27 | 29 | ``` |
28 | 30 |
|
29 | | -### 模式 1:一键安装配置 |
| 31 | +### Examples |
30 | 32 |
|
31 | | -完整的 Docker 安装流程,包括: |
| 33 | +```bash |
| 34 | +# Interactive mode (English, default) |
| 35 | +bash docker.sh |
32 | 36 |
|
33 | | -1. 检测系统发行版并自动配置对应的 Docker CE 仓库 |
34 | | -2. 安装 Docker CE + Docker Compose |
35 | | -3. 配置镜像加速(见下方说明) |
36 | | -4. 启动 Docker 服务并配置开机自启 |
| 37 | +# Interactive mode (Chinese) |
| 38 | +bash docker.sh --lang zh |
37 | 39 |
|
38 | | -### 模式 2:仅修改镜像加速域名 |
| 40 | +# Non-interactive install, no mirror |
| 41 | +bash docker.sh --mode install --yes |
39 | 42 |
|
40 | | -适用于已安装 Docker、仅需更新镜像加速配置的场景。 |
| 43 | +# Non-interactive install with public mirror acceleration |
| 44 | +bash docker.sh --mode install --mirror public --yes |
41 | 45 |
|
42 | | -## 镜像加速配置 |
| 46 | +# Non-interactive install with custom mirror |
| 47 | +bash docker.sh --mode install --mirror hub.example.com --yes |
43 | 48 |
|
44 | | -安装过程中(或模式 2)会提示选择镜像加速方案: |
| 49 | +# Change mirror config only (interactive) |
| 50 | +bash docker.sh --mode mirror |
45 | 51 |
|
| 52 | +# Change mirror config only (non-interactive) |
| 53 | +bash docker.sh --mode mirror --mirror public |
46 | 54 | ``` |
47 | | -请选择镜像加速版本: |
48 | | -1) 使用公共加速域名 (docker.m.daocloud.io) |
49 | | -2) 使用自定义加速域名 (自定义 + docker.m.daocloud.io) |
50 | | -``` |
51 | 55 |
|
52 | | -- **选项 1**:使用 DaoCloud 公共镜像加速,无需任何配置,开箱即用 |
53 | | -- **选项 2**:填入你自己的镜像加速域名(如企业内部加速、自建代理等),脚本会将自定义域名设为优先,DaoCloud 作为兜底 |
| 56 | +## Operation Modes |
| 57 | + |
| 58 | +### Mode: Install (`--mode install`) |
| 59 | + |
| 60 | +Full Docker installation flow: |
| 61 | + |
| 62 | +1. Detect Linux distro and configure the appropriate Docker CE repository |
| 63 | +2. Install Docker CE + Docker Compose |
| 64 | +3. Start Docker service and enable autostart |
| 65 | +4. (Optional) Configure mirror acceleration |
| 66 | +5. Configure user permissions |
| 67 | + |
| 68 | +### Mode: Mirror (`--mode mirror`) |
| 69 | + |
| 70 | +For servers with Docker already installed — update mirror acceleration config only. |
| 71 | + |
| 72 | +## Mirror Acceleration |
| 73 | + |
| 74 | +By default, the script uses Docker's official registry (no mirrors). This is the best choice for servers outside China. |
| 75 | + |
| 76 | +For servers in China, use `--mirror` to configure acceleration: |
54 | 77 |
|
55 | | -配置完成后,脚本会自动写入 `/etc/docker/daemon.json` 并重启 Docker 服务使其生效。 |
| 78 | +| Value | Behavior | |
| 79 | +|-------|----------| |
| 80 | +| `none` (default) | No mirror, use Docker official registry | |
| 81 | +| `public` | Use DaoCloud public mirror (`docker.m.daocloud.io`) | |
| 82 | +| `<domain>` | Use custom domain as priority, DaoCloud as fallback | |
56 | 83 |
|
57 | | -生成的配置示例(选项 2,自定义域名为 `your-mirror.example.com`): |
| 84 | +In interactive mode, the script presents three choices: |
| 85 | + |
| 86 | +``` |
| 87 | +1) No mirror acceleration (default) |
| 88 | +2) Use public mirror (docker.m.daocloud.io) |
| 89 | +3) Use custom mirror domain |
| 90 | +``` |
| 91 | + |
| 92 | +Example `daemon.json` when using `--mirror hub.example.com`: |
58 | 93 |
|
59 | 94 | ```json |
60 | 95 | { |
61 | | - "registry-mirrors": ["https://your-mirror.example.com", "https://docker.m.daocloud.io"], |
62 | | - "insecure-registries": ["your-mirror.example.com"] |
| 96 | + "registry-mirrors": ["https://hub.example.com", "https://docker.m.daocloud.io"], |
| 97 | + "insecure-registries": ["hub.example.com"] |
63 | 98 | } |
64 | 99 | ``` |
65 | 100 |
|
66 | | -## 安装源自动切换 |
67 | | - |
68 | | -脚本内置多个国内镜像源,按以下顺序依次尝试,确保在各种网络环境下都能完成安装: |
69 | | - |
70 | | -1. 阿里云镜像 |
71 | | -2. 腾讯云镜像 |
72 | | -3. 华为云镜像 |
73 | | -4. 中科大镜像 |
74 | | -5. 清华大学镜像 |
75 | | -6. Docker 官方源 |
| 101 | +## Supported Distributions |
76 | 102 |
|
77 | | -## 支持的发行版 |
| 103 | +### RPM-based (CentOS-compatible repo) |
78 | 104 |
|
79 | | -### RPM 系(使用 CentOS 兼容仓库) |
80 | | - |
81 | | -| 发行版 | 支持版本 | 仓库映射 | |
82 | | -|--------|----------|----------| |
83 | | -| CentOS / RHEL | 8, 9, 10 | 对应 el8/el9/el10 | |
84 | | -| Rocky Linux | 8, 9 | 对应 el8/el9 | |
85 | | -| AlmaLinux | 8, 9 | 对应 el8/el9 | |
86 | | -| Oracle Linux | 8, 9 | 对应 el8/el9 | |
| 105 | +| Distribution | Versions | Repo Mapping | |
| 106 | +|-------------|----------|--------------| |
| 107 | +| CentOS / RHEL | 8, 9, 10 | el8/el9/el10 | |
| 108 | +| Rocky Linux | 8, 9 | el8/el9 | |
| 109 | +| AlmaLinux | 8, 9 | el8/el9 | |
| 110 | +| Oracle Linux | 8, 9 | el8/el9 | |
87 | 111 | | openEuler | 20+ | 20→el8, 22+→el9 | |
88 | | -| OpenCloudOS | 9 | el9 兼容 | |
| 112 | +| OpenCloudOS | 9 | el9 | |
89 | 113 | | Anolis OS | 8, 23 | 8→el8, 23→el9 | |
90 | | -| Alibaba Cloud Linux | 3+ | el8 兼容 | |
91 | | -| 银河麒麟 (Kylin) | V10+ | el8 兼容 | |
92 | | -| Fedora | 最新版 | 使用 Fedora 仓库 | |
| 114 | +| Alibaba Cloud Linux | 3+ | el8 | |
| 115 | +| Kylin | V10+ | el8 | |
| 116 | +| Fedora | Latest | Fedora repo | |
93 | 117 |
|
94 | | -### Debian 系(使用 APT 仓库) |
| 118 | +### Debian-based (APT repo) |
95 | 119 |
|
96 | | -| 发行版 | 支持版本 | |
97 | | -|--------|----------| |
| 120 | +| Distribution | Versions | |
| 121 | +|-------------|----------| |
98 | 122 | | Ubuntu | 18.04, 20.04, 22.04, 24.04+ | |
99 | 123 | | Debian | 11 (Bullseye), 12 (Bookworm), 13 (Trixie) | |
100 | | -| Kali Linux | 最新版(使用 Debian 兼容仓库) | |
| 124 | +| Kali Linux | Latest (Debian-compatible repo) | |
| 125 | + |
| 126 | +### Non-Linux |
| 127 | + |
| 128 | +macOS and Windows users will see platform-specific Docker Desktop installation guidance. |
| 129 | + |
| 130 | +## Install Source Failover |
| 131 | + |
| 132 | +The script tries multiple mirror sources in order for best network compatibility: |
101 | 133 |
|
102 | | -### 非 Linux 系统 |
| 134 | +1. Alibaba Cloud Mirror |
| 135 | +2. Tencent Cloud Mirror |
| 136 | +3. Huawei Cloud Mirror |
| 137 | +4. USTC Mirror |
| 138 | +5. Tsinghua University Mirror |
| 139 | +6. Docker Official |
103 | 140 |
|
104 | | -macOS 和 Windows 用户运行脚本后会显示对应平台的安装指引(Docker Desktop)。 |
| 141 | +## Features |
105 | 142 |
|
106 | | -## 特性 |
| 143 | +- Multi-source automatic failover for package downloads |
| 144 | +- Automatic fallback to binary install if package manager fails |
| 145 | +- Docker Compose v2 auto-install |
| 146 | +- Optional mirror acceleration (default: none) |
| 147 | +- i18n support (English / Chinese) |
| 148 | +- Non-interactive mode for automation (`--mode install --yes`) |
| 149 | +- CI validation (17-distro matrix + ShellCheck) |
107 | 150 |
|
108 | | -- 多镜像源自动切换(阿里云 → 腾讯云 → 华为云 → 中科大 → 清华 → 官方) |
109 | | -- 包管理器安装失败时自动回退到二进制安装 |
110 | | -- Docker Compose v2 自动安装 |
111 | | -- 镜像加速自动配置(公共 / 自定义域名) |
112 | | -- CI 自动验证(17 个发行版矩阵 + ShellCheck 静态分析) |
| 151 | +## Development |
113 | 152 |
|
114 | | -## 本地测试 |
| 153 | +### Run tests locally |
115 | 154 |
|
116 | 155 | ```bash |
117 | 156 | bash tests/run_os_matrix.sh |
118 | 157 | ``` |
119 | 158 |
|
120 | | -## CI |
| 159 | +### CI |
121 | 160 |
|
122 | | -- 工作流文件:`.github/workflows/os-compat-ci.yml` |
123 | | -- 触发条件:`push` / `pull_request` 到 `main` |
124 | | -- 测试矩阵: |
125 | | - - **ShellCheck** — 静态分析 |
126 | | - - **RPM 矩阵** — Rocky 8/9, CentOS Stream 10, Alma 8/9, Oracle 8/9, Anolis 23, OpenCloudOS 9, openEuler 24.03 |
127 | | - - **Debian 矩阵** — Ubuntu 24.04/22.04/20.04, Debian 12/11 |
128 | | - - **Fedora 矩阵** — Fedora 41/40 |
| 161 | +- Workflow: `.github/workflows/os-compat-ci.yml` |
| 162 | +- Trigger: `push` / `pull_request` to `main` |
| 163 | +- Jobs: |
| 164 | + - **ShellCheck** — Static analysis |
| 165 | + - **RPM Matrix** — Rocky 8/9, CentOS Stream 10, Alma 8/9, Oracle 8/9, Anolis 23, OpenCloudOS 9, openEuler 24.03 |
| 166 | + - **Debian Matrix** — Ubuntu 24.04/22.04/20.04, Debian 12/11 |
| 167 | + - **Fedora Matrix** — Fedora 41/40 |
129 | 168 |
|
130 | 169 | ## License |
131 | 170 |
|
|
0 commit comments