Manually deploy Docker

更新时间:
复制 MD 格式

This topic describes how to install Docker and Docker Compose on a Linux Simple Application Server instance, and how to deploy containerized applications.

For a quick automated setup, see Quickly deploy Docker. For Docker documentation, see the Docker overview.

Prerequisites

Before you begin, make sure that you have:

Configure registry mirrors

If you experience slow image pulls from Docker Hub due to network issues, you can configure registry mirrors to speed up downloads. Note that this configuration does not apply to the docker search command, which always queries Docker Hub directly.

Note
  • To configure the Alibaba Cloud Container Registry (ACR) image accelerator, log on to the ACR console. In the left-side navigation pane, choose Image Tools > Image Accelerator. On the Image Accelerator page, find your unique accelerator address.

  • An unstable network connection might prevent the accelerator from pulling specific image versions. For more solutions, see Accelerate official image pulls.

  1. Edit the Docker configuration file at /etc/docker/daemon.json. If the file does not exist, create it.

    {
        "registry-mirrors": ["<your-accelerator-address>"]
    }            
  2. Save the file and run the following command to restart the Docker service and apply the changes.

    Important

    Restarting the Docker service causes a brief service interruption. Proceed with caution.

    sudo systemctl restart docker

Supported operating systems

Operating systemPackage manager
Alibaba Cloud Linux 4yum / dnf
Alibaba Cloud Linux 3dnf
Alibaba Cloud Linux 2yum
Ubuntuapt
Debianapt
Red Hatyum
Fedoradnf
Anolis OSyum
CentOS 7.xyum
CentOS 8.xdnf

Install Docker

  1. Connect to your Simple Application Server instance. See Remotely connect to a Linux server.

  2. Follow the steps for your operating system.

Alibaba Cloud Linux 4

Alibaba Cloud Linux 4 ships with Moby as the default container runtime. Choose one of the following options based on your needs:

OptionWhen to use
Moby (recommended)Default for most workloads. Maintained by Alibaba Cloud, optimized for Alibaba Cloud Linux 4, and updated with the OS.
Docker CEUse this when you need Docker Community Edition features not available in Moby, or when you require a specific Docker version.

Step 1: Remove existing Docker components

Before installing, remove any existing Docker components to prevent conflicts.

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
sudo dnf -y remove \
  docker \
  moby \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker

Option A: Install Moby (recommended)

sudo yum install -y moby
Moby is the default container runtime on Alibaba Cloud Linux 4 and will continue to receive updates in future versions. Older Docker components remain available for forward compatibility but will no longer be updated.

Option B: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker CE package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Select a CentOS version: replace $releasever with 9 or 10
# To use CentOS 9:
sudo sed -i 's|$releasever|9|' /etc/yum.repos.d/docker-ce.repo
# To use CentOS 10:
sudo sed -i 's|$releasever|10|' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

To switch back to Moby later:

sudo yum remove -y docker-ce docker-ce-cli
sudo rm -rf /etc/yum.repos.d/docker-ce.repo

Step 3: Start Docker

# Start Docker and enable it to start on boot
sudo systemctl start docker
sudo systemctl enable docker

# Verify the installation
docker --version

Run sudo systemctl status docker to confirm the service is active:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Alibaba Cloud Linux 3

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo dnf -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install the dnf repository compatibility plugin for Alibaba Cloud Linux 3
sudo dnf -y install dnf-plugin-releasever-adapter --repo alinux3-plus

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Ubuntu

Step 1: Remove existing Docker components

# Remove Docker-related package sources
sudo rm -f /etc/apt/sources.list.d/*docker*.list

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
for pkg in docker.io docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-doc docker-compose podman-docker containerd runc; do
  sudo apt-get remove -y $pkg
done

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Update the package list and install prerequisites
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

# Add Docker's GPG key and repository
sudo curl -fsSL http://mirrors.cloud.aliyuncs.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=$(dpkg --print-architecture)] http://mirrors.cloud.aliyuncs.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Debian

Step 1: Remove existing Docker components

# Remove Docker-related package sources
sudo rm -f /etc/apt/sources.list.d/*docker*.list

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
for pkg in docker.io docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-doc docker-compose podman-docker containerd runc; do
  sudo apt-get remove -y $pkg
done

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Update the package list and install prerequisites
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

# Add Docker's GPG key and repository
sudo curl -fsSL http://mirrors.cloud.aliyuncs.com/docker-ce/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=$(dpkg --print-architecture)] http://mirrors.cloud.aliyuncs.com/docker-ce/linux/debian $(lsb_release -cs) stable"

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Red Hat

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo yum -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/rhel/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo yum -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Fedora

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo dnf -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/fedora/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Anolis OS

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo yum -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo yum -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Alibaba Cloud Linux 2

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo yum -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install the yum repository compatibility plugin for Alibaba Cloud Linux 2
sudo yum install yum-plugin-releasever-adapter --disablerepo=* --enablerepo=plus

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo yum -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

CentOS 7.x

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo yum -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo yum -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

CentOS 8.x

Step 1: Remove existing Docker components

# Remove Docker-related package repositories
sudo rm -f /etc/yum.repos.d/docker*.repo

# Uninstall Docker and related packages
# You can ignore messages about packages that are not installed.
sudo dnf -y remove \
  docker-ce \
  containerd.io \
  docker-ce-rootless-extras \
  docker-buildx-plugin \
  docker-ce-cli \
  docker-compose-plugin

Uninstalling Docker does not remove images, containers, volumes, or networks. These are stored in /var/lib/docker/ by default. To remove them, delete this directory manually.

Step 2: Install Docker CE

If you are not using an Alibaba Cloud server, replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com.
# Add the Docker package repository
sudo wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's|https://mirrors.aliyun.com|http://mirrors.cloud.aliyuncs.com|g' /etc/yum.repos.d/docker-ce.repo

# Install Docker CE, containerd.io, and the Buildx and Compose plugins
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is active:

sudo systemctl status docker

Expected output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since ...

Deploy a web application with Docker

This section walks through building a simple Nginx-based web app and running it as a container.

  1. Build the web application image.

    # Pull the latest Nginx image
    sudo docker pull nginx:latest
    
    # Create a Dockerfile using Nginx as the base image,
    # serving a simple "Hello World!" page
    sudo tee Dockerfile <<-'EOF'
    FROM nginx:latest
    RUN echo 'Hello World!' > /usr/share/nginx/html/index.html
    EOF
    
    # Build the image
    sudo docker build . -t hello-world:latest
  2. Start a container named hello-world from the image, mapping port 80.

    sudo docker run -d -p 80:80 --name hello-world hello-world:latest
  3. Verify the web application is running.

    curl http://localhost

    The expected output is:

    Hello World!

Install Docker Compose

Docker Compose is included in the docker-compose-plugin package installed in the previous steps. If you need to install it separately, run the following command for your OS.

If you followed the steps in this topic to install Docker, the Compose plugin is installed by default. Verify the installation by running the following command.

sudo docker compose version

Expected output (where vN.N.N is the version): Docker Compose version vN.N.N.

If the Compose plugin was not installed, or if you prefer to use standalone Compose (docker-compose), see the following sections.

Important
  • When using standalone Compose, include a hyphen in commands, for example, docker-compose up.

  • When using the Compose plugin, run commands without a hyphen, for example, docker compose up.

Compose plugin

Alibaba Cloud Linux 3, CentOS 8.x, and Fedora

sudo dnf -y install docker-compose-plugin

Ubuntu and Debian

sudo apt-get -y install docker-compose-plugin

Alibaba Cloud Linux 2, CentOS 7.x, Red Hat, and Anolis OS

sudo yum -y install docker-compose-plugin

Verify the installation by checking the Compose version.

sudo docker compose version

Standalone Compose

  1. Download and install standalone Compose.

    Note

    You might encounter connection timeouts when accessing GitHub due to network issues. If this occurs, try again.

    curl -SL https://github.com/docker/compose/releases/download/v2.30.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
    # Apply executable permissions to the binary.
    sudo chmod +x /usr/local/bin/docker-compose
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  2. Test the installation by checking the version.

    sudo docker-compose version

Deploy an application with Docker Compose

This section shows how to use Docker Compose to run a WordPress site backed by a MySQL database.

  1. Create a Compose file named docker-compose.yaml.

    sudo tee docker-compose.yaml <<-'EOF'
    version: '3.1'
    
    services:
      wordpress:
        image: wordpress
        restart: always
        ports:
          - "80:80"
        environment:
          WORDPRESS_DB_HOST: wordpress_db
          WORDPRESS_DB_USER: wordpress
          WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
          WORDPRESS_DB_NAME: wordpress
        volumes:
          - wordpress:/var/www/html
    
      db:
        image: mysql:5.7
        restart: always
        container_name: wordpress_db
        environment:
          MYSQL_DATABASE: wordpress
          MYSQL_USER: wordpress
          MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
          MYSQL_RANDOM_ROOT_PASSWORD: ${WORDPRESS_DB_PASSWORD}
        volumes:
          - db:/var/lib/mysql
    
    volumes:
      wordpress:
      db:
    EOF
  2. Start the services.

    export WORDPRESS_DB_PASSWORD=<your-db-password>
    sudo -E docker compose up -d
  3. Open https://<public IP address of the Simple Application Server instance> in a browser. The WordPress setup page appears. Follow the on-screen instructions to complete the configuration.

FAQ

How do I run Docker without sudo?

By default, Docker commands require root privileges. To run Docker as your current user, add the user to the docker group.

  1. Add the current user to the docker group.

    sudo usermod -aG docker $USER
  2. Apply the group change to the current shell session.

    newgrp docker
  3. Verify that your user is now in the docker group.

    groups

    The output should include docker:

    <your-username> sudo docker
  4. Confirm you can run Docker without sudo.

    docker run hello-world

    A success message confirms Docker is working correctly for your user. For the change to persist across login sessions, log out and log back in.

Why is http://mirrors.cloud.aliyuncs.com inaccessible?

If you see a connection failure when accessing http://mirrors.cloud.aliyuncs.com, the possible cause is network instability. Replace http://mirrors.cloud.aliyuncs.com with https://mirrors.aliyun.com in all commands.

https://mirrors.aliyun.com requires your instance to have a public IP address. See Enable Internet access.

Why does the dnf config-manager command fail?

If you see a DeprecationWarning about distutils when running dnf config-manager, your dnf version is outdated. Update it and retry:

sudo dnf update dnf

Why does dnf install docker-ce fail?

Symptom: download failure

containerd.io-1.6.26-3.1.el8.x86_64: Cannot download, all mirrors were already tried without success.

The package cache is stale. Clear it and retry:

sudo dnf clean packages

Symptom: metadata download failure on CentOS 8

Errors during downloading metadata for repository 'base':
  - Curl error (6): Couldn't resolve host name for http://mirror.centos.org/...
Error: Failed to download metadata for repo 'base'

The default CentOS 8 repository is discontinued. Replace it with the Alibaba Cloud-provided archive:

# Back up the existing repo file
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

# Download the Alibaba Cloud CentOS vault repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo

# Update the mirror addresses
sudo sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/CentOS-Base.repo \
  && sudo sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/CentOS-Base.repo \
  && sudo sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS-Base.repo

# Rebuild the cache
sudo yum clean all && sudo yum makecache

Then retry the Docker installation.

What's next