All Products
Search
Document Center

:What do I do if I cannot install Docker by using third-party YUM repositories on an Alibaba Cloud Linux 2 instance?

Last Updated:Apr 10, 2023

This topic describes how to resolve the following issue: Docker cannot be installed by using third-party YUM repositories, such as Docker Community Edition (Docker-CE) and Extra Packages for Enterprise Linux (EPEL) repositories, on an Elastic Compute Service (ECS) instance that runs Alibaba Cloud Linux 2.

Problem description

When you use third-party YUM repositories (such as Docker-CE and EPEL repositories) that are compatible with CentOS 7 and run the yum install docker-ce command to install Docker on an Alibaba Cloud Linux 2 instance that meets the following conditions, Docker cannot be installed and the following error message is returned:

  • The instance uses the Alibaba Cloud Linux 2.1903 LTS 64-bit image.

  • The image used by the instance is aliyun_2_1903_x64_20G_alibase_20210325.vhd or earlier.

Loaded plugins: fastestmirror, langpacks, update-motd
Loading mirror speeds from cached hostfile
  * epel: mirror.sjtu.edu.cn 
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found 
Trying other mirror.
Downloading packages:
docker-ce-20.10.6-3.el7.x86_64 FAILED
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/Packages/docker-ce-20.10.6-3.el7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found 
Trying other mirror.
docker-ce-rootless-extras-20.1 FAILED
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/Packages/docker-ce-rootless-extras-20.10.6-3.el7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found
 Trying other mirror. 


Error downloading packages:
  3:docker-ce-20.10.6-3.el7.x86_64: [Errno 256] No more mirrors to try.
  docker-ce-rootless-extras-20.10.6-3.el7.x86_64: [Errno 256] No more mirrors to try.

Cause

Third-party YUM repositories are compatible only with CentOS 7. The $releasever value of Alibaba Cloud Linux 2 is different from that of CentOS 7. As a result, the Docker package cannot be downloaded because the resolved YUM repository addresses are invalid.

Note

When YUM installs Docker-CE, YUM obtains the version number ($releasever value) from the system and replaces the $releasever value in the baseurl of the corresponding YUM repository with the obtained version number to obtain required data. The $releasever value of CentOS 7 is 7, and the $releasever value of Alibaba Cloud Linux 2 is 2.1903. As a result, the baseurl is resolved to a non-expected address for Alibaba Cloud Linux 2, and YUM cannot obtain the required data from the address.

Solutions

Use one of the following methods to resolve the issue:

Note

In the examples, the Docker-CE repository is used. You can perform the same operations for other YUM repositories.

Solution 1: Change the $releasever value

  1. Log on to the Linux instance.

    For more information, see Connect to a Linux instance by using a password or key.

  2. Run the following command to modify the /etc/yum.repos.d/docker-ce.repo configuration file:

    vim /etc/yum.repos.d/docker-ce.repo
    1. Press the I key to enter the edit mode. In the docker-ce.repo file, find all repositories for which enabled=1 is displayed, and change the $releasever value in the baseurls of the repositories to 7, as shown in the following figure. Dingtalk_20210610100121.jpg

    2. Press the Esc key, enter :wq, and then press Enter to save and close the configuration file. Re-install the Docker software.

Solution 2: Use a plug-in to change the $releasever value

Install the yum-plugin-releasever-adapter plug-in to automatically change the $releasever value from 2.1903 to 7.

  1. Check whether the instance supports the yum-plugin-releasever-adapter plug-in.

    The following table describes the current versions of the yum-plugin-releasever-adapter plug-in and the third-party repositories that are supported by default.

    Plug-in version

    Third-party repository supported by default

    Limits on the plug-in

    1.0-1.3

    Docker-CE and EPEL

    To use the plug-in, make sure that the following requirements are met:

    • The operating system is Alibaba Cloud Linux 2.

    • Run the following command to check whether the plus repository exists:

      cat /etc/yum.repos.d/AliYun.repo |grep -A3 plus

      If a command output similar to the following one is returned, the plus repository exists. Dingtalk_20210622170320.jpg

  2. Log on to the Linux instance.

    For more information, see Connect to a Linux instance by using a password or key.

  3. Run the following command to install the yum-plugin-releasever-adapter plug-in. The plug-in changes the $releasever values of the Docker-CE and EPEL repositories.

    yum install yum-plugin-releasever-adapter --disablerepo=* --enablerepo=plus
  4. If you do not need to change the value of $releasever for other YUM repositories, install the Docker software after the plug-in is installed. If you need to change the value of $releasever for other YUM repositories, perform the following operations:

    1. Run the following command to go to a specified directory:

      cd /etc/yum/pluginconf.d/
    2. Run the following command to modify the releasever-adapter.conf configuration file: If you want to add other YUM repositories, append the .repo file names of the YUM repositories to the includes field. Separate the file names with commas (,).

      vim releasever-adapter.conf

      A command output that is similar to the following one is displayed:

      [main]
      
      enabled=1
      
      hostfilepath=timedhosts.txt
      
      
      [releasevermapping]
      
      release_dict={'2.1903':'7', '3':'8'}
      
      
      [reposlist]
      
      includes=docker-ce.repo, epel.repo
      Note
      • The following parameters are used in the configuration file:

        • [main]: the main control part of the plug-in that is used to enable or disable the plug-in. If enabled is set to 1, the plug-in is enabled. If enabled is set to 0, the plug-in is disabled.

        • [releasevermapping]: the mappings between the $releasever values that you want to change. 2.1903 is mapped to 7, and 3 is mapped to 8.

        • [repolist]: the list of repositories that you want to modify. If you want to add other YUM repositories, append the .repo file names of the repositories to the includes field. Separate the file names with commas (,).

      • A .repo file contains multiple repositories, and each repository has a system-wide unique name. For example, the docker-ce-stable and docker-ce-stable-debuginfo repositories exist at the same time in the docker-ce.repo file.

      • Make sure that each .repo file name added to the releasever-adapter.conf configuration file is the prefix of the names of the repositories that are contained in the .repo file. For example, the docker-ce.repo file contains the docker-ce-stable-debuginfo and docker-ce-stable repositories that share the docker-ce prefix.

    3. Save the configuration file and run the following command to install the Docker software by using the Docker-CE and EPEL repositories.

      yum install docker-ce