Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
docker生成失败,无法解决';archive.ubuntu.com';_Ubuntu_Docker_Boot2docker - Fatal编程技术网

docker生成失败,无法解决';archive.ubuntu.com';

docker生成失败,无法解决';archive.ubuntu.com';,ubuntu,docker,boot2docker,Ubuntu,Docker,Boot2docker,我无法使用以下Dockerfile构建映像: FROM ubuntu RUN apt-get -y update && apt-get -y install \ nodejs npm ssh # cache npm install when package.json hasn't changed WORKDIR /tmp ADD package.json package.json RUN npm install RUN npm install -g pm2 RUN mkdi

我无法使用以下Dockerfile构建映像:

FROM ubuntu

RUN apt-get -y update && apt-get -y install \
nodejs npm ssh

# cache npm install when package.json hasn't changed
WORKDIR /tmp
ADD package.json package.json
RUN npm install
RUN npm install -g pm2

RUN mkdir /sparrow
RUN cp -a /tmp/node_modules /sparrow

WORKDIR /sparrow
ADD . /sparrow/
RUN npm run build

# ssh keys
WORKDIR /root
RUN mv /sparrow/.ssh /root/

# upload js and css
WORKDIR /sparrow/build
# UPLOAD TO S3!

# go back to /sparrow
WORKDIR /sparrow

ENV NODE_ENV production
ENV NODE_PATH "./src"

EXPOSE 8000
CMD ["pm2", "start", "./bin/server.js", "--no-daemon", "-i", "0"]
似乎它在连接到internet以安装ubuntu软件包时遇到问题,并且在以下方面失败:

Err http://archive.ubuntu.com trusty InRelease

Err http://archive.ubuntu.com trusty-updates InRelease

Err http://archive.ubuntu.com trusty-security InRelease

Err http://archive.ubuntu.com trusty Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-security Release.gpg
  Could not resolve 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'archive.ubuntu.com'

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'archive.ubuntu.com'

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'archive.ubuntu.com'

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 nodejs
E: Unable to locate package npm
对如何解决或测试此问题有何建议?在El Capitan OSX上运行

谢谢

这一问题已在

这也会影响到yum和其他repo管理器,因为我们希望它们可以访问,但容器只有主机中允许的网络设置

我喜欢在脚本开头添加以下行:

#DNS update: This is needed to run yum and to let the docker build process access the internet. 
RUN "sh" "-c" "echo nameserver 8.8.8.8 >> /etc/resolv.conf"
更新: 从下面的评论中可以看出:当你在网络之间移动时,比如说在wifi网络之间或者在家庭和工作之间,容器并不知道它在一个新的网络中。重新启动VM或Docker计算机是最佳修复方法。

请参阅。可能发生的情况是,您的VirtualBox NAT DNS代理具有过时的路由。通常必须重新启动VM才能使其重新工作

另一个解决方法是让VM使用主机解析程序(当DHCP分发新的名称服务器时,应该更新主机解析程序)。假设您的机器在Docker machine下命名为
dev
,您可以执行以下操作:

docker-machine stop dev
VBoxManage modifyvm dev --natdnsproxy1 off --natdnshostresolver1 off
docker-machine start dev

在我的Ubuntu主机上,在/etc/default/docker中输入以下条目

DOCKER_OPTS="--dns 172.21.32.182"
然后:

sudo systemctl daemon-reload
sudo systemctl restart docker

帮助解决网络连接问题。当然,您需要用dns替换172.21.32.182。

Docker build因警告而失败
-->[警告]IPv4转发已禁用。网络无法工作
即使您可以解析
archive.ubuntu.com
解决方案-

  • 防火墙打开
  • 在我的情况下,centos7将以下内容添加到 /etc/sysctl.conf:net.ipv4.ip_forward=1
  • 应用sysctl设置: sysctl-p

重新启动VirtualBox VM的可能重复操作修复了我的Mac running Docker Toolbox上的此问题。我的猜测是,当我们在网络之间移动且容器已在运行时,它无法获取新的网络设置。当虚拟机启动后主机位于不同的网络上时,我不确定VirtualBox如何处理这种情况。@ed209您应该将其作为单独的答案发布;)这把戏也是为我做的!是的,这适用于OSX 10.9,docker机器docker机器版本0.5.4,docker 1.9.1;非常感谢你,只有最后两行工作正常,解决了我所有的问题!