部署Docker(Ubuntu)
前提条件
安装Docker
- 以root用户登录服务器,配置信任Docker的GPG公钥,命令如下:
curl -fsSL https://repo.huaweicloud.com/docker-ce/linux/debian/gpg | sudo apt-key add -
- 执行以下命令,更新源并安装Docker。
apt-get update apt-get install -y docker-ce
如果执行apt-get update命令时,出现类似如下所示报错,则执行apt-get update --allow-unauthenticated命令。
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.
- 执行systemctl start docker命令启动Docker。
- 执行docker version命令,如回显类似以下信息表示Docker已安装并启动。
Client: Docker Engine - Community Version: 20.10.7 API version: 1.41 Go version: go1.13.15 Git commit: f0df350 Built: Wed Jun 30 19:55:49 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.7 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: b0f5bc3 Built: Wed Jun 30 19:54:13 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.9 GitCommit: e25210fe30a0a703442421b0f60afac609f950a3 runc: Version: 1.0.1 GitCommit: v1.0.1-0-g4144b63 docker-init: Version: 0.19.0 GitCommit: de40ad0
父主题: 部署Docker