部署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 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是否已启动,如显示以下信息表示Docker已安装并启动。
Client: Docker Engine - Community Version: 20.10.7 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 30 19:55:49 2021 OS/Arch: linux/arm64 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.8 Git commit: 20.10.7-Oubuntu5~18.04.3 Built: Fri Oct 22 19:54:13 2021 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.10 GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
父主题: 部署Docker