目前,docker一般是部署在Linux7以上的系统,其要求Linux系统内核在3.8或更高的版本。
Ubuntu查看内核版本信息的两种方法: cat /proc/version uname -a Ubuntu查看发行版本信息的方法: cat /etc/issue2. 卸载旧版本
如果安装了docker的旧版本,需将旧版本的docker容器卸载: sudo apt-get remove docker docker-engine docker.io containerd runc3. 安装相关apt依赖
先更新一下: sudo apt-get update 安装相关依赖: sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common4. 添加GPG密钥,并添加Docker-ce软件源
官方的GPG密钥及软件源(速度较慢,不推荐): curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 中科大的GPG密钥及软件源: curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"5. 更新apt
再更新一次apt: sudo apt-get update6. 安装docker容器及相关程序
sudo apt-get install docker-ce docker-ce-cli containerd.io7. 查看已安装好的docker版本信息
docker version8. 测试运行
sudo docker run hello-world
显示如下就成功了
9. 配置镜像加速默认访问的仓库地址在国外,因此访问速度可能较慢。为了更方便的使用docker,可以配置阿里云的镜像加速。
9.1 查看是否存在daemon.json文件cd /etc/docker ls --------- key.json9.2 创建daemon.json文件
touch daemon.json9.3 编辑daemon.json文件
sudo gedit /etc/docker/daemon.json
在弹出来的文本文件中写入以下内容:
{
"registry-mirrors": ["https://4e2ek1nn.mirror.aliyuncs.com"]
}
如果想配置中科大的镜像加速,则写入以下内容:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
可以使用以下命令查看文件中写入的内容:
cat daemon.json
9.4 重启docker,完成配置
sudo systemctl daemon-reload sudo systemctl restart docker



