Home > other >  Docker build failure, cannot resolve 'archive.ubuntu.com'
Docker build failure, cannot resolve 'archive.ubuntu.com'

Time:02-12

I can't use the following Dockerfile build my image:

The FROM ubuntu

The RUN apt - get - y update & amp; & Apt - get - y install \
Nodejs NPM SSH

# cache NPM install the when package. Json hasn 't changed
WORKDIR/TMP
ADD package. Json package. Json
The RUN NPM install
The RUN NPM install - g pm2

RUN the mkdir/sparrow
The RUN cp - a/TMP/node_modules/sparrow

WORKDIR/sparrow
The ADD./sparrow/
The RUN NPM RUN build

# SSH keys
WORKDIR/root
The RUN/sparrow/mv. 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", "the./bin/server. Js", "- no - the daemon", "-i", "0"]

It seems to be unable to connect to the Internet to install ubuntu packages and failure:

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

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

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

Err, http://archive.ubuntu.com trusty the GPG
Could not resolve 'archive.ubuntu.com'
Err, http://archive.ubuntu.com trusty - updates the GPG
Could not resolve 'archive.ubuntu.com'
Err, http://archive.ubuntu.com trusty ws-security the GPG
Could not resolve 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch HTTP://http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease

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

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

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

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

W: Failed to fetch HTTP://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 had been ignored, or old ones home, informs.
Reading package lists...
Building the dependency tree...
Reading the state information...
E: Unable to locate package nodejs
E: Unable to locate package NPM

Any suggestion on the problem of how to solve or test this? In the El Capitan OSX running on
Thank you very much!

CodePudding user response:

This has already answered the Docker build "Could not resolve the 'archive.ubuntu.com'" apt - get fails to install anything
It will also affect the yum and other 'manager, because we hope they can visit, but the container only host allows network Settings
I want to add these lines at the beginning of the script:

# DNS update: This is men to run yum and let the docker build process access to the Internet,
RUN "sh" "-" c "echo nameserver 8.8.8.8 & gt;> The/etc/resolv. Conf "

Update: from the comments: when you are in the network, said the move between between the wireless network or between work and family, the container didn't know it in the new network. Restart the VM or Docker machine is the best solution.

CodePudding user response:

have to solve
  • Related