Dockerfile:Docker build不能下载软件包:centos-> yum,debian / ubuntu-> apt-get intranet [英] Dockerfile: Docker build can't download packages: centos->yum, debian/ubuntu->apt-get behind intranet

查看:813
本文介绍了Dockerfile:Docker build不能下载软件包:centos-> yum,debian / ubuntu-> apt-get intranet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



环境:我有一个Mac OS X,运行VMWare与一个guest Ubuntu 14.04,运行Docker:

  mdesales @ ubuntu〜$ sudo docker版本
客户端版本:1.1.2
客户端API版本:1.13
Go版本(客户端):go1.2.1
Git提交(客户端):d84a070
服务器版本:1.1.2
服务器API版本: 1.13
Go版本(服务器):go1.2.1
Git提交(服务器):d84a070


$ b b

行为:使用docker build无法下载软件包。以下是此类Dockerfile的示例: https://github.com/Krijger/docker-cookbooks / blob / master / jdk8-oracle / Dockerfile https://github.com/ottenhoff / centos-java / blob / master / Dockerfile



我知道我们可以使用--dns运行一个容器,但这是在构建时。




  • CENTOS



    FROM centos
    abc


  • UBUNTU



    FROM ubuntu
    RUN apt-get install abc




用户已报告可能是DNS配置的问题,其他人的配置和Google的DNS服务器已注释掉。 p>

 步骤2:运行yum install -y curl; yum升级yum update -y; yum clean all 
--->在5f11b65c87b8
中运行加载的插件:fastestmirror
无法解析主机'mirrorlist.centos.org

仍然问题仍然存在...所以,#docker @ Freenode的大多数用户提到它可能是DNS配置的问题...所以这里是我的Ubuntu:

  $ sudo cat /etc/resolv.conf 
nameserver 127.0.1.1
搜索localdomain
pre>

我试图改变,同样的问题...

解决方案

PROBLEM



在#docker @ freenode与一些开发人员交谈时,问题是每个人都清楚:DNS和环境。在家里的常规互联网连接的构建工作正常。



解决方案:



服务器或网络阻止Google的DNS服务器。即使docker容器可以ping 8.8.8.8,构建仍然需要访问防火墙或数据中心后面的相同的私有DNS服务器。



启动Docker守护进程使用--dns开关指向您的私有DNS服务器,就像配置主机操作系统一样。



我的MAC OS X ,主机操作系统,在我的/etc/resolv.conf配置了不同的DNS:

  mdesales @ Marcello-Work〜 )$ cat /etc/resolv.conf 
search corp.my-private-company.net
nameserver 172.18.20.13
nameserver 172.20.100.29

我的主机可能会将数据包丢弃到Google的IP地址8.8.8.8,而构建...我只是把这2个IP地址放在Ubuntu的docker守护程序配置:

  mdesales @ ubuntu〜$ cat / etc / default / docker 
...
...
#使用DOCKER_OPTS修改守护进程启动选项。
DOCKER_OPTS = - dns 172.18.20.13 --dns 172.20.100.29 --dns 8.8.8.8
...

这个版本现在可以正常工作了!

  $ sudo ./build.sh 
向Docker守护进程发送构建上下文7.168 kB
向Docker守护进程发送构建上下文
步骤0:FROM centos
---> b157b77b1a65
步骤1:MAINTAINER Marcello_deSales@intuit.com
--->在49bc6e233e4c中运行
---> 2a380810ffda
删除中间容器49bc6e233e4c
步骤2:运行yum install -y curl; yum升级yum update -y; yum clean all
--->在5f11b65c87b8
中运行加载的插件:fastestmirror
确定最快的镜像
* base:mirror.supremebytes.com
* extras:centos.mirror.ndchost.com
*更新:mirrors.tummy.com
解析依赖关系
- >运行事务检查
--->软件包systemd.x86_64 0:208-11.el7将更新
--->软件包systemd.x86_64 0:208-11.el7_0.2将更新
--->软件包systemd-libs.x86_64 0:208-11.el7将更新
--->软件包systemd-libs.x86_64 0:208-11.el7_0.2将更新
- >完成依赖性解决方案

感谢@BrianF和其他在IRC频道中帮助!



永久VM解决方案 - 2015年7月2日更新



我们现在有GitHub Enterprise和CoreOS Enterprise Docker注册表在混合...所以,我很重要的是,从HOST机器添加公司的DNS服务器,以使VM也能工作。



更换/etc/resolv.conf从客户操作系统与主机的/etc/resolv.conf也解决了问题! Docker 1.7.0。我刚刚在VMWare Fusion上使用Ubuntu 15.04创建了一个新VM,我又遇到了这个问题...



/etc/resolv.conf BEFORE

 〜/ dev / github / public / stackedit on⭠master⌚20:31:02 
$ cat / etc /resolv.conf
#resolvconf(8)生成的glibc解析器(3)的动态resolv.conf(5)文件
#不要修改这个文件 - 你的更改将被覆盖
nameserver 127.0.1.1
search localdomain

/etc/resolv.conf AFTER *

 〜/ dev / github / public / stackedit on⭠master⌚20:56:09 
$ cat /etc/resolv.conf
#resolvconf(8)生成的glibc解析器(3)的动态resolv.conf(5)文件
#不要手动编辑这个文件更改将超过
搜索corp.mycompany.net
nameserver 10.180.194.35
nameserver 10.180.194.36
nameserver 192.168.1.1


PROBLEM: Any build, with a Dockerfile depending on centos, ubuntu or debian fails to build.

ENVIRONMENT: I have a Mac OS X, running VMWare with a guest Ubuntu 14.04, running Docker:

mdesales@ubuntu ~ $ sudo docker version
Client version: 1.1.2
Client API version: 1.13
Go version (client): go1.2.1
Git commit (client): d84a070
Server version: 1.1.2
Server API version: 1.13
Go version (server): go1.2.1
Git commit (server): d84a070

BEHAVIOR: Using "docker build" fails to download packages. Here's an example of such Dockerfile: https://github.com/Krijger/docker-cookbooks/blob/master/jdk8-oracle/Dockerfile, https://github.com/ottenhoff/centos-java/blob/master/Dockerfile

I know that we can run a container with --dns, but this is during the build time.

  • CENTOS

    FROM centos RUN yum install a b c

  • UBUNTU

    FROM ubuntu RUN apt-get install a b c

Users have reported that it might be problems with DNS configuration, others and the configuration has the Google's DNS servers commented out.

Step 2 : RUN yum install -y curl; yum upgrade -y; yum update -y;  yum clean all
 ---> Running in 5f11b65c87b8
Loaded plugins: fastestmirror
Couldn't resolve host 'mirrorlist.centos.org

Still the problem persisted... So, most users on #docker@Freenode mentioned that it might be a problem with the DNS configuration... So here's my Ubuntu:

$ sudo cat /etc/resolv.conf 
nameserver 127.0.1.1
search localdomain

I tried changing that, same problem...

解决方案

PROBLEM

Talking to some developers at #docker@freenode, the problem was clear to everyone: DNS and the environment. The build works just fine at a regular Internet connection at home.

SOLUTION:

This problem occurs in an environment that has a private DNS server, or the network blocks the Google's DNS servers. Even if the docker container can ping 8.8.8.8, the build still needs to have access to the same private DNS server behind your firewall or Data Center.

Start the Docker daemon with the --dns switch to point to your private DNS server, just like your host OS is configured. That was found by trial and error.

Details

My MAC OS X, host OS, had a different DNS configured on my /etc/resolv.conf:

mdesales@Marcello-Work ~ (mac) $ cat /etc/resolv.conf
search corp.my-private-company.net
nameserver 172.18.20.13
nameserver 172.20.100.29

My host might be dropping the packets to the Google's IP address 8.8.8.8 while building... I just took those 2 IP addresses and placed under the Ubuntu's docker daemon configuration:

mdesales@ubuntu ~ $ cat /etc/default/docker
...
...
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 172.18.20.13 --dns 172.20.100.29 --dns 8.8.8.8"
...

The build now works as expected!

$ sudo ./build.sh 
Sending build context to Docker daemon 7.168 kB
Sending build context to Docker daemon 
Step 0 : FROM centos
 ---> b157b77b1a65
Step 1 : MAINTAINER Marcello_deSales@intuit.com
 ---> Running in 49bc6e233e4c
 ---> 2a380810ffda
Removing intermediate container 49bc6e233e4c
Step 2 : RUN yum install -y curl; yum upgrade -y; yum update -y;  yum clean all
 ---> Running in 5f11b65c87b8
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.supremebytes.com
 * extras: centos.mirror.ndchost.com
 * updates: mirrors.tummy.com
Resolving Dependencies
--> Running transaction check
---> Package systemd.x86_64 0:208-11.el7 will be updated
---> Package systemd.x86_64 0:208-11.el7_0.2 will be an update
---> Package systemd-libs.x86_64 0:208-11.el7 will be updated
---> Package systemd-libs.x86_64 0:208-11.el7_0.2 will be an update
--> Finished Dependency Resolution

Thanks to @BrianF and others who helped in the IRC channel!

Permanent VM Solution - UPDATE JULY 2, 2015

We now have GitHub Enterprise and CoreOS Enterprise Docker Registry in the mix... So, it was important for me to add the corporate DNS servers from the HOST machine in order to get the VM also to work.

Replacing the /etc/resolv.conf from the guest OS with the Host's /etc/resolv.conf also resolved the problem! Docker 1.7.0. I just created a new VM using Ubuntu 15.04 on VMWare Fusion and I had this problem again...

/etc/resolv.conf BEFORE

~/dev/github/public/stackedit on ⭠ master ⌚ 20:31:02
$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search localdomain

/etc/resolv.conf AFTER*

~/dev/github/public/stackedit on ⭠ master ⌚ 20:56:09
$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
search corp.mycompany.net
nameserver 10.180.194.35
nameserver 10.180.194.36
nameserver 192.168.1.1

这篇关于Dockerfile:Docker build不能下载软件包:centos-> yum,debian / ubuntu-> apt-get intranet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆