本文已参与「新人创作礼」活动,一起开启掘金创作之路。
先展示成功拉取镜像
再设置个docker命令开机自启
正文: 在ubuntu上安装docker docs.docker.com/install/lin… 对系统要求,它只支持 Ubuntu Hirsute 21.04 Ubuntu Groovy 20.10 Ubuntu Focal 20.04 (LTS) Ubuntu Bionic 18.04 (LTS) 系统架构的话,它支持x86_64 (or amd64), armhf, and arm64 architectures
(假设你已经在windows系统上用XSHELL远程连接上了linux服务器) Ps:不会使用XSHELL远程连接服务器的话请参考“XSHELL安装指南”
然后先卸载之前安装过的旧版本 sudo apt-get remove docker docker-engine docker.io containerd runc Ps:如果没有安装过旧版本可以不用执行
1.更新一下软件园: sudo apt-get update
2.通过HTTP去访问一些软件园的组件 sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
3.添加官方的GPG密钥 curl -fsSL download.docker.com/linux/ubunt… | sudo apt-key add-
显示“OK”就可以了
4.用官方提供的搜索指纹去对比 sudo apt-key fingerprint 0EBFCD88
看到和官方提供的是一样的
5.添加官方镜像源 先通过 lsb_release -cs 查看ubuntu版本号
这个说明ubuntu版本是18.04 docker这里选用稳定版
sudo add-apt-repository “deb [arch=amd64] download.docker.com/linux/ubunt… $(lsb_release -cs) Stable”
更行成功
7.安装docker sudo apt-get install docker-ce docker-ce-cli containerd.io
这个地方我是之前下载过了,所以是从缓存中去解包,第一次下载的话应该是从官方的软件园去解包
8.验证docker是否装好 sudo docker run hello-world
这样就是成功了!
但是很容易出现这样的错误: docker pull时,pull不下来镜像。 Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: www.docker.com/increase-ra… 解决方法: 更改daemon.json(/etc/docker/daemon.json),变更了镜像极速器的地址。用了科大的镜像加速器 “registry-mirrors”: [“docker.mirrors.ustc.edu.cn/”]
systemctl daemon-reload && systemctl restart docker 如果没有systemctl daemon-reload,而直接systemctl restart docker 的话,docke pull时还是有问题
docker 重启后,docker pull 正常了。
Author:Lmy