dockerapt-get

Docker build "Could not resolve 'archive.ubuntu.com'" apt-get fails to install anything


I've been trying to run Docker build on various files which previously worked before, which are now no longer working.

As soon as the Docker file included any line that was to install software it would fail with a message saying that the package was not found.

RUN apt-get -y install supervisor nodejs npm

The common message which showed up in the logs was

Could not resolve 'archive.ubuntu.com'

Any idea why any software will not install?


Solution

  • After much headache I found the answer. Could not resolve 'archive.ubuntu.com' can be fixed by making the following changes:

    1. Uncomment the following line in /etc/default/docker
      DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

    2. Restart the Docker service sudo service docker restart

    3. Delete any images which have cached the invalid DNS settings.

    4. Build again and the problem should be solved.

    Credit goes to Andrew SB