> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# Docker 官方安装脚本使用镜像
- URL: https://sgpublic.xyz/p/2025/04/6aac9cb1810a48000153360e/
- Published: 2025-04-14T03:54:02.000Z
- Updated: 2026-09-18T04:05:00.000Z
- Author: Haven Madray
- Tags: 基础设施, Docker, #wp-post

之前尝试在国内的 ECS 实例里安装 docker，尝试运行以下命令：

```bash
curl -fsSL https://get.docker.com | bash

```

结果如下：

```bash
ecs-user@iZ2vc4s2mp8t4ikopho8pnZ:~/frps$ sudo bash ./docker-installer.sh 
# Executing docker install script, commit: 4c94a56999e10efcf48c5b8e3f6afea464f9108e
+ sh -c 'apt-get -qq update >/dev/null'
+ sh -c 'DEBIAN_FRONTEND=noninteractive apt-get -y -qq install ca-certificates curl >/dev/null'
+ sh -c 'install -m 0755 -d /etc/apt/keyrings'
+ sh -c 'curl -fsSL "https://download.docker.com/linux/debian/gpg" -o /etc/apt/keyrings/docker.asc'
+ sh -c 'chmod a+r /etc/apt/keyrings/docker.asc'
+ sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" > /etc/apt/sources.list.d/docker.list'
+ sh -c 'apt-get -qq update >/dev/null'
W: Failed to fetch https://download.docker.com/linux/debian/dists/bookworm/InRelease  Could not handshake: Error in the pull function. [IP: 3.170.229.111 443]
W: Some index files failed to download. They have been ignored, or old ones used instead.
+ sh -c 'DEBIAN_FRONTEND=noninteractive apt-get -y -qq install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null'
E: Package 'docker-ce' has no installation candidate
E: Package 'docker-ce-cli' has no installation candidate
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'
E: Unable to locate package docker-compose-plugin
E: Package 'docker-ce-rootless-extras' has no installation candidate
E: Unable to locate package docker-buildx-plugin

```

显然，`download.docker.com` 在国内访问不畅。阅读脚本内容，发现如下注释：

```bash
# Alternatively, use the script at https://test.docker.com, which uses the test
# channel as default.
#
# --mirror <aliyun|azurechinacloud>
#
# Use the --mirror option to install from a mirror supported by this script.
# Available mirrors are "Aliyun" (https://mirrors.aliyun.com/docker-ce), and
# "AzureChinaCloud" (https://mirror.azure.cn/docker-ce), for example:
#
#   $ sudo sh install-docker.sh --mirror AzureChinaCloud

```

也就是说，这个脚本是允许使用镜像源的，于是将安装命令改为：

```bash
curl -fsSL https://get.docker.com | bash -s -- --mirror Aliyun

```

再次执行即可安装成功。</aliyun|azurechinacloud>