How can I stop Docker from trying to connect to docker.io?

0
9
Asked By CuriousCoder42 On

I'm currently in China, and I've run into issues pulling Docker images because Docker keeps trying to connect to docker.io instead of a local mirror or an alternative registry. For instance, when I try to pull images like this:
```bash
user@host:~ $ docker pull docker.n8n.io/n8nio/n8n
Using default tag: latest

Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
```
I've added a Chinese mirror as shown by running `docker info`, but Docker still tries to reach out to docker.io:
```text
Registry Mirrors:
https://registry.docker-cn.com/
```
I even checked the Docker binary for potential hard-coded references to docker.io using:
```bash
grep -rn "registry-1.docker.io" /usr/bin/docker
grep: /usr/bin/docker: binary file matches
```
Does anyone know how to make Docker completely avoid connecting to docker.io?

2 Answers

Answered By TechGuru88 On

You can actually manage the image sources in Docker's configuration file. Look for `daemon.json` under `/etc/docker/` and set your preferred registry there. Just be sure to follow the documentation to ensure it's set up correctly! Also, double-check your mirrors to make sure they're properly configured.

Answered By DockerDabbler33 On

A workaround could be to add an entry to your hosts file, like this:

```
127.0.0.1 registry-1.docker.io
```
This would redirect requests for docker.io to your local machine. But keep in mind, it might just lead to a different error since Docker might try to connect and fail on localhost instead.

CuriousCoder42 -

How would that even help? Seems like just a swap for a different error.

DockerDabbler33 -

True, it might just create a new issue with the connection refused error unless you set up your own HTTPS server locally. It's more of a creative hack than a solid fix!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.