-
安装docker。参考官方文档 https://docs.docker.com/engine/install/ubuntu/
卸载旧docker
sudo apt-get -y remove docker docker-engine docker.io containerd runc
安装一些依赖软件
sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
阿里云上安装可以看这里
镜像加速
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
安装curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - sudo apt-key fingerprint 0EBFCD88
设置为稳定版源(阿里云)
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
https://blog.csdn.net/qq_30935743/article/details/107977665
安装官方 GPG keycurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
设置为稳定版源
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
更新源并安装最新稳定版docker(安装指定版本docker可以参考官方文档)
sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get install -y docker-ce docker-ce-cli containerd.io
验证是否安装成功
sudo docker run hello-world
出现以下画面即表示安装成功
将用户加入docker组中,避免每次运行需要sudo
sudo usermod -aG docker <user>