Docker无法解析'deb.debian.org' [英] Docker Could not resolve 'deb.debian.org'

查看:916
本文介绍了Docker无法解析'deb.debian.org'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Docker中构建一个容器以进行一些实验。这是我的 Dockerfile

  FROM debian 

运行mkdir -p / var / run / sshd

运行apt-get更新
运行apt-get安装-y openssh服务器

运行apt-得到安装-y sudo

RUN echo AddressFamily inet>> / etc / ssh / sshd_config

ARG username = Rivers
ARG userpasswd = perfectXJ2017

RUN useradd -ms / bin / bash $ username& (echo $ username:$ userpasswd | chpasswd)

RUN adduser $ username sudo

CMD / usr / sbin / sshd -D

我尝试使用命令 sudo docker build -t ics-image来构建映像。



但是后来我收到一些错误消息,整个过程停止了。这是错误消息。

 将构建上下文发送到Docker守护程序2.048kB 
步骤1/11:FROM debian
---> 8626492fecd3
步骤2/11:运行mkdir -p / var / run / sshd
--->在1e1f2dbbe5ca
中运行删除中间容器1e1f2dbbe5ca
---> dd4bec2f81d4
步骤3/11:运行apt-get update
--->在022301215bfb中运行
Get:1 http://security.debian.org/debian-security Stretch / updates InRelease [94.3 kB]
Get:2 http://security.debian.org/debian-安全性Stretch / updates / main amd64软件包[450 kB]
错误:3 http://deb.debian.org/debian Stretch InRelease
无法解析'deb.debian.org'
错误:4 http://deb.debian.org/debian Stretch-updates InRelease
无法解析'deb.debian.org'
在20秒内获得544 kB(26.9 kB / s)
读取软件包列表...
W:无法获取http://deb.debian.org/debian/dists/stretch/InRelease无法解析'deb.debian.org'
W:失败来获取http://deb.debian.org/debian/dists/stretch-updates/InRelease无法解析'deb.debian.org'
W:某些索引文件无法下载。它们已被忽略,或改用旧的。
移除中间容器022301215bfb
---> 054d32710b62
步骤4/11:运行apt-get install -y openssh-server
--->在802d2fa37b8d中运行
正在读取软件包列表...
正在构建依赖关系树...
正在读取状态信息...
软件包openssh-server不可用,但由引用。另一个包裹。
这可能意味着该软件包丢失,已被废弃或仅从其他来源获得


E:软件包 openssh-server没有安装候选对象
命令'/ bin / sh -c apt-get install -y openssh-server'返回非零代码:100

我在Ubuntu 18.04上完成了所有这些工作。我不明白为什么会这样以及如何解决这个问题。有人可以帮忙吗?

解决方案

您应该首先检查是否能够解析 deb.debian.org。 从运行docker的主机中获取。您可以使用
nslookup deb.debian.org dig deb.debian.org 进行检查。 / p>

如果您无法解析主机,请将名称服务器8.8.8.8 添加到您的 /etc/resolv.conf 文件,然后重试。
Docker从 /etc/resolv.conf 文件复制名称服务器。



或者您可以设置名称服务器通过创建文件 /etc/docker/daemon.json

  {
dns:[ 8.8.8.8]
}

然后重新启动docker服务:

  $服务docker restart 


I was trying to build a container in Docker for some experiments. Here is my Dockerfile.

FROM debian

RUN mkdir -p /var/run/sshd

RUN apt-get update
RUN apt-get install -y openssh-server

RUN apt-get install -y sudo

RUN echo AddressFamily inet >> /etc/ssh/sshd_config

ARG username=Rivers
ARG userpasswd=perfectXJ2017

RUN useradd -ms /bin/bash $username && (echo $username:$userpasswd | chpasswd)

RUN adduser $username sudo

CMD /usr/sbin/sshd -D

I tried to build my image with the command sudo docker build -t ics-image ..

But then I got some error messages and the whole process stopped. Here is the error messages.

Sending build context to Docker daemon  2.048kB
Step 1/11 : FROM debian
 ---> 8626492fecd3
Step 2/11 : RUN mkdir -p /var/run/sshd
 ---> Running in 1e1f2dbbe5ca
Removing intermediate container 1e1f2dbbe5ca
 ---> dd4bec2f81d4
Step 3/11 : RUN apt-get update
 ---> Running in 022301215bfb
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:2 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [450 kB]
Err:3 http://deb.debian.org/debian stretch InRelease
  Could not resolve 'deb.debian.org'
Err:4 http://deb.debian.org/debian stretch-updates InRelease
  Could not resolve 'deb.debian.org'
Fetched 544 kB in 20s (26.9 kB/s)
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Could not resolve 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Could not resolve 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Removing intermediate container 022301215bfb
 ---> 054d32710b62
Step 4/11 : RUN apt-get install -y openssh-server
 ---> Running in 802d2fa37b8d
Reading package lists...
Building dependency tree...
Reading state information...
Package openssh-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'openssh-server' has no installation candidate
The command '/bin/sh -c apt-get install -y openssh-server' returned a non-zero code: 100

I did all this on Ubuntu 18.04. I cannot understand why this happened and how to solve this problem. Can anyone help?

解决方案

You should first check if you are able to resolve deb.debian.org from your host in which you are running docker. You can check that with nslookup deb.debian.org or dig deb.debian.org.

If you are not able to resolve the from host add nameserver 8.8.8.8 to your /etc/resolv.conf file and then try again. Docker copies nameservers from /etc/resolv.conf file.

Or you can set the nameserver by creating file /etc/docker/daemon.json

{
    "dns": ["8.8.8.8"]
}

then restart docker service:

$ service docker restart

这篇关于Docker无法解析'deb.debian.org'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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