在Ubuntu上安装Docker分为以下几个步骤:
- 更新包列表:
sudo apt update
- 安装依赖包,以便允许
apt
使用HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- 添加Docker官方GPG密钥,以验证下载的Docker软件包:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 添加Docker APT仓库:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
这将向/etc/apt/sources.list.d/docker.list
中添加Docker仓库。
- 更新包列表:
sudo apt update
- 安装Docker:
sudo apt install docker-ce docker-ce-cli containerd.io
- 启动Docker服务:
sudo systemctl start docker
- 设置Docker自动启动:
sudo systemctl enable docker
- 验证Docker安装:
sudo docker --version