Docker on localhost error: dial tcp: lookup localhost on 8.8.8.8:53: no such host

Viewed 5152

I'm having this error when starting a docker service, the full error message says:

FATA[0000] version check: failed to get version from server: failed making version api call: Get "http://localhost:8080/v1/version": dial tcp: lookup localhost on 8.8.8.8:53: no such host

I've done already what's suggested here but nothing seems to work, and I dont clearly understand what's going on here :(

2 Answers

You can try two approaches to resolve this:

  1. Try to change localhost to 127.0.0.1
  2. Check your etc/hosts file to see if there is an entry for localhost. If there isn't any, just add it as follows:

vim /etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost  <- add this line

if you want access host's localhost. you should change

localhost to host.docker.internal

docker's localhost is container localhost.

Related