One-Command Docker Setup for Chinese Servers: Fast, Secure, Mirror‑Optimized
This guide shows how a single shell script can automatically detect the Linux distribution, install Docker CE using Alibaba Cloud mirrors, configure three domestic registry accelerators, and verify the installation, providing a fast and secure Docker environment for developers in China.
In the previous articles the author introduced a Docker‑based personal music library and a remote‑work solution. This article provides a ready‑to‑use docker‑compose.yml file but many users get stuck at the first step: installing Docker, which can be cumbersome and slow in China due to network restrictions.
What the Script Does
Automatic OS detection – supports Rocky Linux, CentOS, RHEL, AlmaLinux (8/9); other systems abort with an error.
Installs Docker CE from Alibaba Cloud mirrors – avoids the timeout of official mirrors and speeds up download by more than five times.
Configures three domestic registry accelerators – adds https://docker.1ms.run, https://hub.rat.dev, and https://docker.xuanyuan.me to /etc/docker/daemon.json, any of which can accelerate docker pull.
One‑line, fully automated execution .
Quick Start: Single Command
Run the following as root or with sudo:
curl -fsSL https://download.xlsys.cn/tools/Shell/install-docker.sh | sudo bashOptional: Download First for Security Concerns
curl -fsSL https://download.xlsys.cn/tools/Shell/install-docker.sh -o install-docker.sh
sudo bash install-docker.shVerify Installation
# Verify Docker
docker run --rm hello-world
# Verify Compose (example)
mkdir test-compose && cd test-compose
cat > docker-compose.yml <<EOF
version: "3"
services:
app:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
restart: "always"
volumes:
- /etc/localtime:/etc/localtime
- /run/docker.sock:/run/docker.sock
- /sj-data/web/uptime:/app/data
ports:
- "3001:3001"
EOF
docker compose up -dManual Checks
# Docker version
docker --version
# Compose V2 status
docker compose version
# Registry mirrors loaded
docker info | grep -A 3 "Registry Mirrors"What the Script Modifies
It adds a Docker repository to /etc/yum.repos.d/, creates or overwrites /etc/docker/daemon.json, and enables and starts the Docker service.
Final Thoughts
Docker itself is straightforward; the real challenges are network restrictions, environment differences, and configuration omissions. This script aims to eliminate those hassles, turning a complex setup into a routine task.
Xiao Liu Lab
An operations lab passionate about server tinkering 🔬 Sharing automation scripts, high-availability architecture, alert optimization, and incident reviews. Using technology to reduce overtime and experience to avoid major pitfalls. Follow me for easier, more reliable operations!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
