更新软件包索引:

sudo apt-get update

安装必要的软件包,以允许apt通过HTTPS使用仓库:

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

添加Docker的官方GPG密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

设置稳定版仓库:

echo \
  "deb [arch=$(dpkg --print-architecture) 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

更新软件包索引:

sudo apt-get update

安装最新版本的Docker Engine和containerd:

sudo apt-get install docker-ce docker-ce-cli containerd.io

验证Docker是否安装成功并运行:

sudo systemctl status docker

设置Docker开机自启动:

sudo systemctl enable docker

如果需要非root用户运行Docker命令,请执行以下命令添加用户至docker组:

sudo usermod -aG docker $USER

安装Docker管理工具Portainer:

docker pull portainer/portainer-ce
docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /root/portainer_data:/data portainer/portainer-ce

登录:http://localhost:9000