小白初次上手docker,光安装就花费了老半天时间,中间出现的各种问题也是无从下手,还好最终解决掉了。话不多少,直接上图。
首先安装最新版Docker CE(社区版)
sudo apt-get install docker-ce
通过运行hello-world 映像来验证是否正确安装了Docker Engine-Community 。
sudo docker run hello-world
然后就哭了,半天不行,各种问题啊,要奔溃。。。咱也不懂直接百度吧。
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled (Client.Timeout exceeded while awaiting headers).
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: TLS handshake timeout.
百度解决方案:
docker在本地没有找到hello-world镜像,docker服务器再国外,我们在国内
无法正常拉取镜像,所以就需要我们为docker设置国内阿里云的镜像加速器;修改配置文件 vim /etc/docker/daemon.json
,创建一个json文件 touch daemon.json
,修改文件的权限 chmod 777 daemon.json
{
"registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"]
}
然后会提示同样的错误。继续百度
终于看到曙光了,说是多添加几个源试试,死马当活马医吧,没什么别的好办法了。
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8","8.8.4.4"]
}
重新加载daemon文件并重启docker
sudo systemctl daemon-reload
sudo service docker restart
神奇的一幕出现了: