我无法使用以下Dockerfile构build映像:
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"]
似乎有连接到互联网安装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
有关如何解决或testing此问题的任何build议? 在El Capitan OSX上运行
谢谢!
这已经在Docker构建“无法解决”archive.ubuntu.com“”apt-get无法安装任何东西
这也影响yum和其他回购管理器,因为我们期望它们是可访问的,但容器只有主机允许的网络设置
我喜欢在我的脚本开始处添加这些行:
#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机器是最好的解决方案。
在我的Ubuntu主机上,在/ etc / default / docker下面的条目
DOCKER_OPTS="--dns 172.21.32.182"
接着:
sudo systemctl daemon-reload sudo systemctl restart docker
帮助解决了网络连接问题。 当然你需要用你的dns替换172.21.32.182。
请参阅https://github.com/boot2docker/boot2docker/issues/451#issuecomment-65432123 。 可能发生的事情是你的VirtualBox NAT DNS代理有一个陈旧的路线。 您通常必须重新启动虚拟机才能再次运行。
另一个解决方法是让虚拟机使用您的主机解析器(当DHCP实施新名称服务器时应该更新)。 假设你的机器在Docker Machine下被命名为dev
,你可以这样做:
docker-machine stop dev VBoxManage modifyvm dev --natdnsproxy1 off --natdnshostresolver1 off docker-machine start dev
Docker构建失败,因为警告---> [Warning] IPv4 forwarding is disabled. Networking will not work
即使您可以解决archive.ubuntu.com
---> [Warning] IPv4 forwarding is disabled. Networking will not work
解决方案 –