Docker学习过程中遇到的错误
Docker学习过程中遇到的错误
1)使用docker拉取nginx出现的错误,以及解决方法:
使用“docker pull nginx”拉取镜像时,出现 Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) 的错误。在此之前直接使用"docker pull nginx",出现类似的错误,大概意思是连接超时的网络问题。
经过 ping 108.160.169.179 出现100%丢包,物理机上也ping不同(100%丢包)。然后使用阿里云的镜像加速器依然出先上述问题,重新设置NDS服务器也不行。
上网查询到在国内已经禁用从docker上拉取nginx(大概就是这个意思,在国内禁用了无法拉取),然后尝试走网络代理,不知道哪里出的问题,也不行。
最后的解决方式是:
docker pull registry.cn-shenzhen.aliyuncs.com/amgs/nginx:latest
这个是使用的是在国内的镜像拉取的nginx,原先的拉取命令docker pull nginx的意思是从docker官方的镜像拉拉取,也就是说即使使用了阿里云云的镜像加速器,其实还是从官方那里拉取的,自然是出现连接超时的问题。
2)使用docker运行nginx时出现的错误
使用 “docker run -d nginx:latest” 出现错误:Unable to find image 'nginx:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on [::1]:53: read udp [::1]:42651->[::1]:53: read: connection refused.
意思是不能发现这个nginx镜像在docker(疑惑已经下载在docker里,却没有发现nginx镜像,原因可能是从镜像里拉取的镜像所以需要运行时,不应该是这样写命令,该命令运行的是正经从官网拉取下来的......等等原因,大概就是这个意思)
然后再次尝试“docker run -d nginx:latest”和“docker run -detach --name web nginx”,再次出现错误“Unable to find image 'nginx:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on [::1]:53: read udp [::1]:42651->[::1]:53: read: connection refused.”。与上面是一样的错误。(docker run -d nginx:latest,其中-d表示在后台运行)
解决方式:
docker run -d -p 8080:80 --name my-custom-nginx registry.cn-shenzhen.aliyuncs.com/amgs/nginx:latest
-d:让容器在后台运行。-p 8080:80:将主机的 8080 端口映射到容器的 80 端口,这样你就能够通过http://localhost:8080来访问 Nginx 服务了。--name my-custom-nginx:给容器命名为my-custom-nginx,方便后续管理。registry.cn-shenzhen.aliyuncs.com/amgs/nginx:latest:指定要运行的镜像名称。
本文来自博客园,作者:里莉,转载请注明原文链接:https://www.cnblogs.com/liliisme/p/18831643

浙公网安备 33010602011771号