Ubuntu(Ubuntu 22.04 操作系统) 安装 Docker

发布时间 2023-09-23 12:10:58作者: liuzonglin

Ubuntu(Ubuntu 22.04 操作系统) 安装 Docker

首先安装一些工具:

sudo apt-get install ca-certificates curl gnupg lsb-release

不过在Ubuntu22.04已经默认安装好了。接着安装官方的GPG key:

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

最后将Docker的库添加到apt资源列表中:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

接着我们更新一次apt:

 sudo apt update

最后安装Docker CE版本:

 sudo apt install docker-ce

等待安装完成就可以了:

最后我们将当前用户添加到docker用户组中,不然每次使用docker命令都需要sudo执行,很麻烦:

sudo usermod -aG docker <用户名>

配置好后,我们先退出SSH终端,然后重新连接就可以生效了。

参考文档: