一、官网教程地址
官网地址: https://docs.docker.com/install/linux/docker-ce/ubuntu/
二、安装步骤
1. 卸载旧版本(若先前未安装过,可省略此步骤):
sudo apt-get remove docker docker-engine docker.io containerd runc
2.更新apt:
sudo apt-get update
3.添加证书安装包以允许apt通过HTTPS:
sudo apt-get install
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common
4.添加Docker的官方GPG密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
5.添加仓库:
sudo add-apt-repository
“deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable”
6.安装docker ce:
sudo apt-get install docker-ce docker-ce-cli containerd.io
7. 测试
sudo docker run hello-world
8.查看当前安装的docker版本:
docker --version
9… 添加当前用户到 docker 用户组
sudo usermod -aG docker pyvip
三、阿里云换源
可能我们会在执行sudo apt-get update的时候会发生一些小错误,因此提供除了如下解决方法:
① 进入根目录下的/etc/apt中找到source.list
②vim进入其中,在命令模式下输入ggdG删除所有内容,再进入插入模式添加如下内容:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
③进入末行模式输入wq保存退出即可
④此时再次执行命令 sudo apt-get update 即可更新软件
感谢大家观看,有不懂的地方欢迎留言讨论!!!