Friday, 13 December 2024

Docker lookup registry-1.docker.io: no such host

 https://stackoverflow.com/questions/46036152/lookup-registry-1-docker-io-no-such-host

a) Add nameserver 8.8.8.8

Method #1

docker-machine ssh default
sudo vi /etc/resolv.conf
//change nameserver to 8.8.8.8

Then restart the server using

service docker restart

Note: If you don't have docker-machine installed, you can follow instructions here to install it. It comes with Windows and Mac but is available for install on Linux manually.

Method #2

Edit /etc/docker/daemon.json Or "provide a JSON configuration in the preference panel" with the following information:

{ "dns" : [ "8.8.8.8", "8.8.4.4" ]}

Then restart the server using

service docker restart

b) Setup Proxy

Method #1

Edit your proxy configuration as Tarun Lalwani suggested.

Edit /etc/default/docker and add:

export http_proxy='http://username:password@proxy-host:proxy-port'
export https_proxy='https://username:password@proxy-host:proxy-port'

Then restart the server using

service docker restart

Method #2

Source: https://github.com/moby/moby/issues/32270#issuecomment-340709035

  1. Create a systemd drop-in directory for the docker service:

    mkdir -p /etc/systemd/system/docker.service.d
    # For HTTP Proxy:
    vim /etc/systemd/system/docker.service.d/http-proxy.conf
    # For HTTPS Proxy:
    vim /etc/systemd/system/docker.service.d/https-proxy.conf
    
  2. Then add below content with proxy settings with it (Change to "HTTPS" for https)

    [Service]
    Environment="HTTP_PROXY=http://<allowed_proxy_ipv4_address>:<proxy_port_num>/"
    [Service]
    
  3. sudo systemctl daemon-reload

  4. sudo systemctl restart docker
  5. Verify that the configuration has been loaded: systemctl show --property=Environment docker

c) Reinstall Docker

Unfortunately the last resort, could work. Check out these github pages for more suggestions:

For me, setting up the proxy using the systemctl method was the only thing that worked.

No comments:

Post a Comment