English
Docker Binary Installation Guide in the Context of CentOS 7 EOL

Background Information
CentOS 7 has already been June 30, 2024 Officially discontinued maintenance (End of Life, EOL). This means:
Official yum repository (
mirror.centos.org)is no longer availableThird-party repositories such as EPEL are successively ending support for CentOS 7.
through
yumInstalling Docker will face the issue of being unable to download dependency packages.
In this context,Binary deployment Become the most reliable and direct way to install Docker on CentOS 7.
Solution Advantages
| Comparison item | yum install | Binary installation |
|---|---|---|
| Dependency handling | Need to resolve dependencies such as container-selinux. | Completely dependency-free, runs directly. |
| Source availability | CentOS 7 repositories become invalid after EOL | No impact, just download the tar package directly. |
| Installation speed | Depends on network and source speed. | Quickly, complete it within 5 minutes. |
| Applicable scenarios | An environment with a stable source | Legacy systems, offline environments, EOL systems |
| Upgrade method | yum update Automatic upgrade | Manually download the new version and replace it. |
Precondition
Operating system: CentOS 7 (kernel version ≥ 3.10)
Network environment: able to access the official Docker download site or Alibaba Cloud mirror site
User permissions: root or with sudo privileges
Check kernel version:
bash
uname -r
# Example output: 5.14.21-20230616.el7.x86_64Installation Steps
Step 1: Download the Docker binary package
bash
# Enter the temporary directory
cd /tmp
# Install wget (skip if already installed)
sudo yum install -y wget
# Download from the official source (recommended)
sudo wget https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz
# Or download from the Alibaba Cloud mirror (recommended for users in China)
# sudo wget https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-26.1.4.tgzVersion Notes:26.1.4 is a verified stable version. To access other versions, please visit:
Official: https://download.docker.com/linux/static/stable/x86_64/
Alibaba Cloud: https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/
Step 2: Extract and install the binary files
bash
# Extract the archive
sudo tar -xzvf docker-26.1.4.tgz
# Copy the binary file to the system PATH
sudo cp docker/* /usr/bin/At this point, the Docker core commands (docker,dockerd etc.) are already available, but still need to be configured as system services to start automatically on boot.
Step 3: Create the Docker user group (optional)
bash
# Create docker user group
sudo groupadd docker
# Add the current user to the docker group (to avoid using sudo every time)
sudo usermod -aG docker $USERStep 4: Configure the systemd service
Create a systemd service file for Docker so that it can be systemctl Management:
bash
sudo cat > /etc/systemd/system/docker.service << 'EOF'
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOFStep 5: Start the Docker service
bash
# Reload systemd configuration
sudo systemctl daemon-reload
# Start Docker
sudo systemctl start docker
# Set to start on boot
sudo systemctl enable docker
# Check service status
sudo systemctl status dockerStep 6: Verify the installation
bash
# View Docker version information
sudo docker version
# Run the hello-world container to verify
sudo docker run hello-worldIf you see the following output, the installation was successful:
Hello from Docker!
This message shows that your installation appears to be working correctly.
...Common troubleshooting
1. Non-root users cannot run Docker commands
bash
# Log in again or execute the following command
newgrp docker2. Startup failed, indicating a "devicemapper"-related error
CentOS 7 kernel supports by default overlay2 Storage driver, no additional configuration required. Check the storage driver:
bash
sudo docker info | grep "Storage Driver"
# Should output: Storage Driver: overlay23. Firewall prevents containers from accessing the network
bash
# Temporarily disable the firewall (for testing)
sudo systemctl stop firewalld
# Or open the ports required by Docker
sudo firewall-cmd --permanent --add-port=2375/tcp
sudo firewall-cmd --reload4. Download link is invalid
If a version update causes the link to return 404, you can visit the download directory to get the latest version number:
bash
# Official download directory
curl -s https://download.docker.com/linux/static/stable/x86_64/ | grep -o 'docker-[0-9.]*\.tgz' | sort -V | tail -1
# Alibaba Cloud mirror directory
curl -s https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/ | grep -o 'docker-[0-9.]*\.tgz' | sort -V | tail -1Recommended follow-up actions
Configure Docker daemon proxy
Important: The Docker daemon (dockerd) does not read shell environment variables and must be configured separately.
bash
# 1. Create Docker service configuration directory
sudo mkdir -p /etc/systemd/system/docker.service.d
# 2. Write proxy configuration
sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<'EOF'
[Service]
Environment="HTTP_PROXY=http://192.168.0.237:7890"
Environment="HTTPS_PROXY=http://192.168.0.237:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.local,.aliyuncs.com"
EOF
# 3. Reload and restart Docker (must be executed after subsequent installation)
# sudo systemctl daemon-reload
# sudo systemctl restart docker⚠️ Pitfall reminder: Do not include .docker.io in NO_PROXY, otherwise Docker Hub traffic will not go through the proxy.
Configure Docker image accelerator
Create or modify /etc/docker/daemon.json:
bash
sudo mkdir -p /etc/docker
sudo cat > /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://free.hubfast.cn"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
}
}
EOF
# Restart Docker to apply the configuration.
sudo systemctl restart docker⚠️ Docker 镜像加速器参考
Upgrade Docker version
When an upgrade is required, download the new version package and overwrite it./usr/bin/ the binary file under [the directory], then restart the service:
bash
# Download new version
wget https://download.docker.com/linux/static/stable/x86_64/docker-new version number.tgz
tar -xzvf docker-new-version-number.tgz
sudo cp docker/* /usr/bin/
# Restart service
sudo systemctl restart dockerSummary
Against the backdrop of CentOS 7 EOL, installing Docker from binaries offers the following significant advantages:
Bypass invalid sources Without relying on any yum repository, directly download the official precompiled package.
No dependency conflicts: No processing required
container-selinux,slirp4netnsand other dependency packagesRapid deployment: Complete the entire process from download to verification within 5 minutes
Strong controllability: Can precisely specify versions, facilitating offline deployment and version management
Although CentOS 7 has reached end of life, Docker can still run stably on it through binary installation, providing a feasible path for containerizing legacy systems.
Reference materials
Suggestion: For production environments, please plan to migrate to actively maintained distributions such as Rocky Linux / AlmaLinux as soon as possible.