Deploying the Docker
Before creating a container image and deploying a container, make sure that Docker has been deployed on the host. This document describes how to deploy Docker on a host running Ubuntu or CentOS. The image OS in the container can be a different one.
Deploying Docker (Ubuntu)
Before configuring the source, make sure that the installation environment can connect to the network. If your server cannot directly connect to the external network, you need to configure a network proxy. For details, see Configuring a System Network Proxy.
Check whether the source is correct in the /etc/apt/sources.list file. If no source is specified in file, configure an available source.
You can access the source repository, and locate the directory corresponding to the onsite OS architecture and version. Open the source.list file, and copy the source link in the file to the /etc/apt/sources.list file on the server. The file should contain the Docker CE-related source, for example, deb https://mirrors.huaweicloud.com/docker-ce/linux/ubuntu/ focal stable.
Docker installation method:
- Log in to the server as the root user and run the following command to configure the trusted Docker GPG public key:
curl -fsSL https://repo.huaweicloud.com/docker-ce/linux/debian/gpg | sudo apt-key add -
- Run the following commands to update the source and install the Docker:
apt-get update apt-get install docker-ce
If any of the below error messages is displayed when you run the apt-get update command, run the apt-get update --allow-unauthenticated command.
Err:1 https://repo.huaweicloud.com/docker-ce/linux/ubuntu focal InRelease Temporary failure resolving 'repo.huaweicloud.com' Err:2 https://mirrors.huaweicloud.com/ubuntu-ports focal InRelease Temporary failure resolving 'mirrors.huaweicloud.com' Err:3 https://mirrors.huaweicloud.com/ubuntu-ports focal-updates InRelease Temporary failure resolving 'mirrors.huaweicloud.com' Err:4 https://mirrors.huaweicloud.com/ubuntu-ports focal-security InRelease Temporary failure resolving 'mirrors.huaweicloud.com' Err:5 https://mirrors.huaweicloud.com/docker-ce/linux/ubuntu focal InRelease Temporary failure resolving 'mirrors.huaweicloud.com' Reading package lists... Done N: Ignoring file 'index.html' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension W: Failed to fetch https://mirrors.huaweicloud.com/ubuntu-ports/dists/focal/InRelease Temporary failure resolving 'mirrors.huaweicloud.com' W: Failed to fetch https://mirrors.huaweicloud.com/ubuntu-ports/dists/focal-updates/InRelease Temporary failure resolving 'mirrors.huaweicloud.com' W: Failed to fetch https://mirrors.huaweicloud.com/ubuntu-ports/dists/focal-security/InRelease Temporary failure resolving 'mirrors.huaweicloud.com' W: Failed to fetch https://mirrors.huaweicloud.com/docker-ce/linux/ubuntu/dists/focal/InRelease Temporary failure resolving 'mirrors.huaweicloud.com' W: Failed to fetch https://repo.huaweicloud.com/docker-ce/linux/ubuntu/dists/focal/InRelease Temporary failure resolving 'repo.huaweicloud.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
Deploying Docker (CentOS)
Before configuring the source, make sure that the installation environment can connect to the network. For details about how to configure a network proxy, see Configuring a System Network Proxy.
Check whether the docker-ce.repo source file exists in /etc/yum.repos.d. If yes, check the source validity. If there is no source file or source configuration, configure an available source.
You can access the source repository, and locate the directory corresponding to the onsite OS architecture and version. Open the source.repo file, copy the source link in the file to the /etc/yum.repos.d/ CentOS-Base.repo file on the server.
The file should contain the Docker CE related source, for example, baseurl=https://mirrors.huaweicloud.com/docker-ce/linux/centos/7/aarch64/stable/.
Docker installation method:
- Log in to the server as the root user.
- Run the following commands to update the source and install Docker:
yum makecache fast yum install docker-ce
If the Docker fails to be installed due to the following error,
Public key for containerd.io-1.6.6-3.1.el7.xx.rpm is not installed
run the yum --nogpgcheck install docker-ce command to install the Docker.
- Run the docker version command to check whether the Docker has been started. If the following information is displayed, the Docker has been installed and started:
Client: Docker Engine - Community Version: 20.10.17 API version: 1.41 Go version: go1.17.11 Git commit: 100c701 Built: Mon Jun 6 23:03:34 2022 OS/Arch: linux/arm64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.17 API version: 1.41 (minimum version 1.12) Go version: go1.17.11 Git commit: a89b842 Built: Mon Jun 6 23:02:14 2022 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.6 GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1 runc: Version: 1.1.2 GitCommit: v1.1.2-0-ga916309 docker-init: Version: 0.19.0 GitCommit: de40ad0
If information similar to the following is displayed, the Docker has been installed but not started. Run the service docker start command to start the Docker.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?