Docker installation tutorial under CentOS details

  • 2021-01-14 07:13:30
  • OfStack

Docker is divided into CE and EE. The CE version is the Community version (free). EE is the enterprise version, with an emphasis on security (paid for). Docker releases 1 edge version every month and 1 stable version every 3 months. Docker, EE and stable version numbers remain the same.

Docker CE supports the 64-bit version CentOS 7 and requires kernel version 3.10 or higher. CentOS meets the minimum kernel requirements. If the kernel version is low, some functions (such as overlay2 storage layer driver) cannot be used, and some functions may be unstable.

There are three ways to install Docker CE: through the Docker repository, manually by downloading the installation package, or automatically through a script.

Most users use the Docker repository's mirrored source installation, which is easier to install and upgrade, and is the preferred method. Some users download the installation package for manual installation, which is more useful in the case of unable to connect to the network, as long as there is an installation package. In development and test environments, some users install it through autoscripts, which is also convenient but not recommended in production environments. There are several risks. First, the script requires root permissions, so you need to check the script carefully before running it. Second, the script will attempt to detect the version of your system and configure your package management system. In addition, the script will not allow you to customize any installation parameters. This may result in an unsupported configuration. Again, the script installs dependent packages without acknowledgement, which may install a large number of packages, depending on your current host configuration; And this method does not determine which version to download, it only installs the latest version.

Install using yum source

The official source


$ sudo yum-config-manager \
  --add-repo \
  https://download.docker.com/linux/centos/docker-ce.repo

Domestic source


$ sudo yum-config-manager \
  --add-repo \
  https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo

Step 1: the above two sources to choose 1, 1 generally in view of domestic network problems, usually choose domestic sources. However, if you are installing Docker CE for the first time on your host, you will need to set up the Docker repository first. After that, you will be able to install and update Docker through this repository. Otherwise, the following prompt will appear: sudo: yum-config-manager: 找不到命令 .

The solution is to set up the repository and install the necessary packages yum-utils . This package provides yum-config-manager The function. The same is true for Docker and CE devicemapper Storage drivers also require two additional packages device-mapper-persistent-data and lvm2 . We pass command 1 below and install.


$ sudo yum install -y yum-utils \
 device-mapper-persistent-data \
 lvm2

Install Docker CE


$ sudo yum install docker-ce

During the installation process, you will be asked if you want to continue. Simply type y.

Automatically installed through a script

In order to simplify the installation process in a test or development environment, Docker officials provide a handy set of installation scripts that can be used on CentOS systems.


$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh -mirror Aliyun

After executing the above command, the script will automatically get the first step ready and install the edge version of Docker CE on the system.

Start the Docker

Docker installed in the first way above requires manual startup, while a script installation automatically starts Docker. Starting Docker is also simple, with the following command $ sudo systemctl start docker .

References:

Get Docker CE for CentOS

conclusion


Related articles: