在构建Docker图像时无法找到包 [英] Unable to locate package while building Docker image

查看:263
本文介绍了在构建Docker图像时无法找到包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Docker容器构建过程中,我尝试使用apt-get install安装一些软件包。但是,由于没有找到4个软件包中的3个,所以进程无法完成。

 步骤1:运行apt-get更新&安培;&安培; apt-get install -y netcat ca-certificates build-essential libssl-dev 
--->运行在38d22d97ec4a
Err http://http.debian.net jessie InRelease

Err http://http.debian.net jessie-updates InRelease

Err http://security.debian.org jessie / updates InRelease

Err http://http.debian.net jessie Release.gpg
无法解析http.debian.net
Err http://security.debian.org jessie / updates Release.gpg
无法解析'security.debian.org'
Err http://http.debian.net jessie-updates Release.gpg
无法解析'http.debian.net'
阅读包列表...
W:无法获取http://http.debian.net/debian/dists/ jessie / InRelease

W:无法提取http://http.debian.net/debian/dists/jessie-updates/InRelease

W:无法获取http: //security.debian.org/dists/jessie/updates/InRelease

W:无法提取http://http.debian.net/debian/dists/jessie/Release.gpg无法解决'http.debian.net'

W:无法提取http://http.debian.net/debian/ dists / jessie-updates / Release.gpg无法解析'http.debian.net'

W:无法获取http://security.debian.org/dists/jessie/updates/Release。 gpg无法解析'security.debian.org'

W:某些索引文件无法下载。他们被忽视了,或者旧的被使用了。
读取包列表...
构建依赖关系树...
读取状态信息...
E:无法找到包netcat
E:无法找到package build-essential
E:无法找到包libssl-dev
删除中间容器38d22d97ec4a
2015/08/10 12:03:07命令[/ bin / sh -c apt-获取更新&& apt-get install -y netcat ca-certificates build-essential libssl-dev]返回一个非零代码:100

起初,我以为这是我的基本图像的一个问题,但是我没有在另一个VM上构建容器的问题。想法?

解决方案

这个问题围绕主机的网络配置。 eth0接口配置不正确。以下命令帮助我确定这是一个DNS问题。

  $ docker run --rm debian:jessie ping -c 5 google .com 
ping:未知主机
$ docker运行--rm debian:jessie ping -c 5 8.8.8.8
PING 8.8.8.8(8.8.8.8):56个数据字节
从8.8.8.8开始的64字节:icmp_seq = 0 ttl = 38时间= 37.147 ms
从8.8.8.8开始的64个字节:icmp_seq = 1 ttl = 38 time = 32.917 ms
从8.8.8.8开始的64个字节: icmp_seq = 2 ttl = 38 time = 31.475 ms
从8.8.8.8开始的64个字节:icmp_seq = 3 ttl = 38 time = 30.692 ms
从8.8.8.8开始的64个字节:icmp_seq = 4 ttl = 38 time = 31.180 ms
--- 8.8.8.8 ping统计---
5个数据包发送,5个数据包接收,0%丢包
往返最小/ avg / max / stddev = 30.692 / 32.682 / 37.147 / 2.352 ms


During my Docker container build process, I attemptted to install a few packages using apt-get install. However the process failed to complete because the 3 of the 4 packages could not be found.

Step 1 : RUN apt-get update  && apt-get install -y netcat  ca-certificates  build-essential  libssl-dev
 ---> Running in 38d22d97ec4a
Err http://http.debian.net jessie InRelease

Err http://http.debian.net jessie-updates InRelease

Err http://security.debian.org jessie/updates InRelease

Err http://http.debian.net jessie Release.gpg
  Could not resolve 'http.debian.net'
Err http://security.debian.org jessie/updates Release.gpg
  Could not resolve 'security.debian.org'
Err http://http.debian.net jessie-updates Release.gpg
  Could not resolve 'http.debian.net'
Reading package lists...
W: Failed to fetch http://http.debian.net/debian/dists/jessie/InRelease

W: Failed to fetch http://http.debian.net/debian/dists/jessie-updates/InRelease 

W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease

W: Failed to fetch http://http.debian.net/debian/dists/jessie/Release.gpg  Could not resolve 'http.debian.net'

W: Failed to fetch http://http.debian.net/debian/dists/jessie-updates/Release.gpg  Could not resolve 'http.debian.net'

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Could not resolve 'security.debian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package netcat
E: Unable to locate package build-essential
E: Unable to locate package libssl-dev
Removing intermediate container 38d22d97ec4a
2015/08/10 12:03:07 The command [/bin/sh -c apt-get update  && apt-get install -y netcat  ca-certificates  build-essential  libssl-dev] returned a non-zero code: 100

At first, I thought this was an issue with my base image, however I have no issues building the container on another VM. Thoughts?

解决方案

This issue revolved around the host's network configuration. The eth0 interface was improperly configured. The following commands helped me determine it was a DNS issue.

$ docker run --rm debian:jessie ping -c 5 google.com
ping: unknown host
$ docker run --rm debian:jessie ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=38 time=37.147 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=38 time=32.917 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=38 time=31.475 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=38 time=30.692 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=38 time=31.180 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 30.692/32.682/37.147/2.352 ms

这篇关于在构建Docker图像时无法找到包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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