问题描述
我在构建docker映像时遇到问题,并尝试了其他DNS选项,但似乎没有运气。
I have a problem with building docker image and tried different DNS option but seems no luck.
Docker版本1.9.1,构建a34a1d5
Docker version 1.9.1, build a34a1d5
回购还活着。
为了运行容器,我使用了 docker run --dns = 192.168.1.1 -d -ti --name alpine3 alpine
标记,dns在那里工作。
Repos are alive.For running container I used docker run --dns=192.168.1.1 -d -ti --name alpine3 alpine
tag and dns works weel there.
对于图像,我将DNS IP 192.168.1.1添加到了/etc/docker/daemon.json和/etc/default/docker.io以及docker eth DNS中,但这没有
For images I added my DNS IP 192.168.1.1 to /etc/docker/daemon.json and /etc/default/docker.io and to docker eth DNS but this didn't help.
然后我重新启动了docker服务多次并重新拉出了高山图像。
And I restarted docker service many times and re-pulled alpine image.
我什至在本地创建了使用本地主机进行回购,在构建过程中可以通过日志中的路径访问本地主机,我可以下载所需的文件,但是运行docker build时会收到错误。
I even created local repo with localhost which is reachable with path in the log during build, I can download needed file, but when I run docker build I receive errors.
doc1@ubuntu:$ docker build -t web .
Sending build context to Docker daemon 5.632 kB
Step 1 : FROM alpine
---> 3c82203aab43
Step 2 : MAINTAINER y0zg
---> Using cache
---> 16cc74909dc2
Step 3 : RUN echo http://localhost > /etc/apk/repositories; echo http://nl.alpinelinux.org/alpine/v3.6/main >> /etc/apk/repositories
---> Using cache
---> b7f808daeb7b
Step 4 : RUN apk --no-cache update
---> Running in f6625eaa1d7d
fetch http://localhost/x86_64/APKINDEX.tar.gz
ERROR: http://localhost: could not connect to server (check repositories file)
fetch http://localhost/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://localhost/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
fetch http://nl.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
ERROR: http://nl.alpinelinux.org/alpine/v3.6/main: temporary error (try again later)
2 errors; 11 distinct packages available
这里是dockerfile
Here is dockerfile
doc1@ubuntu:$ cat Dockerfile
FROM alpine
MAINTAINER y0zg
RUN echo http://localhost > /etc/apk/repositories; \
echo http://nl.alpinelinux.org/alpine/v3.6/main >> /etc/apk/repositories
RUN apk --no-cache update
ADD counter.rb counter.rb
EXPOSE 4567
ENTRYPOINT ["ruby","counter.rb"]
推荐答案
这是DNS问题,您可以使用以下步骤:
It's DNS issue you can solve it by using the following steps:
1)使用以下命令查找您的DNS IP
1) Find your DNS ip using below command
nmcli dev show | grep 'IP4.DNS'
IP4.DNS [1]:192.168.0.1
IP4.DNS[1]: 192.168.0.1
2)在桌面上创建一个文件,文件名为 deamon.json
,文件包含以下数据:
{
dns:[ 192.168.0.1, 8.8.8.8]
}
2) Create a file in the desktop which name is deamon.json
and file has below data:{"dns": ["192.168.0.1", "8.8.8.8"]}
注意:将ip 192.168.0.1
替换为您的dns ip
note: replace that ip 192.168.0.1
to your dns ip
3)在系统中转到该目录 / etc / docker /
并粘贴文件 deamon.json
3) Go that directory /etc/docker/
in your system and paste file deamon.json
that you just created
4)然后重新启动docker / your系统,它将解决您的问题。
4) Then restart your docker/your system, it will solve your issue.
这篇关于映像生成错误期间docker repo解决错误(检查存储库文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!