我無法使用以下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"]
似乎它無法連接到互聯網以安裝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上運行
謝謝!
uj5u.com熱心網友回復:
這已經回答了Docker build “Could not resolve ‘archive.ubuntu.com'” apt-get fails to install anything這也會影響yum和其他repo manger,因為我們希望它們可以訪問,但容器只有主機允許的網路設定
我想在腳本的開頭添加這些行:
#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"
更新:從下面的評論:當您在網路之間移動時說在無線網路之間或家庭和作業之間,容器不知道它在新網路中.重啟VM或Docker機器是最好的解決方案.
uj5u.com熱心網友回復:
有解決嗎
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/258854.html
標籤:其他技術討論專區
下一篇:RuntimeError: Boolean value of Tensor with more than one value is ambiguous
