13/10/2026

Docker Hub in Iran: use a mirror, or run your own cache

You've probably seen this. You run `docker pull nginx` on a server in Iran and you either get a 403 or it just hangs until it times out. It's not your fault. Docker Hub blocks Iranian IPs. So your pulls need to go through something in the middle instead of `registry-1.docker.io`. That can be a mirror run by an Iranian company, or a registry you host yourself.

You've probably seen this. You run docker pull nginx on a server in Iran and you either get a 403 or it just hangs until it times out. It's not your fault. Docker Hub blocks Iranian IPs. So your pulls need to go through something in the middle instead of registry-1.docker.io. That can be a mirror run by an Iranian company, or a registry you host yourself.

Quick bit of news. On October 12, 2026, Iran launched a "National Open Source Repository" with over 21 million packages (Tasnim). I haven't found a Docker endpoint for it yet. If an official one shows up, I'll add it here.

So you've got three options. One server or a laptop? A ready-made mirror is enough, five minutes and you're done. A few servers or a cluster? Run a local cache with registry:2 so each image only comes in from outside once. A team that needs users, access control and scanning? Go with Harbor.

A ready-made mirror in daemon.json

First thing to know: Docker only uses mirrors for Docker Hub. Images from ghcr.io or quay.io won't go through this.

The file is /etc/docker/daemon.json. Heads up, JSON doesn't allow comments.

json@itcorv:~
{
  "registry-mirrors": [
    "https://docker.arvancloud.ir",
    "https://registry.docker.ir"
  ]
}

Then restart Docker and check that it picked up the mirror:

bash@itcorv:~
sudo systemctl restart docker
docker info | grep -A3 "Registry Mirrors"
docker pull alpine:3.20

If you already have a daemon.json, don't wipe it. Just add registry-mirrors. One missing comma and dockerd won't start at all. If you list several mirrors and the first one doesn't answer, Docker tries the next one, and finally Docker Hub itself.

These are the Iranian mirrors I checked. All of them returned 200 or 401 on /v2/, so there's a live registry behind the address. Keep in mind I tested on October 12, 2026 from a server outside Iran. Test again from a server inside Iran before you rely on them.

| Provider | Address | |---|---| | ArvanCloud | https://docker.arvancloud.ir | | docker.ir | https://registry.docker.ir | | HamDocker | https://hub.hamdocker.ir | | Chabokan | https://mirror2.chabokan.net | | Abrha (ParsPack) | https://docker.abrha.net |

One more thing. Some people also add insecure-registries. With an https address you don't need it. All it does is skip TLS checks for that address.

Chinese or Iranian mirror? Depends on the internet

Here's the important part. When things are normal and international internet works, you can use Chinese mirrors from inside Iran too. They're usually more complete and new tags show up there sooner. But if the internet gets cut and only the national network is up, the Chinese ones are gone and only Iranian mirrors work. So the smart move is to have both.

These are the Chinese mirrors I checked. They returned 200 or 401 on /v2/ and sent the Docker-Distribution-Api-Version: registry/2.0 header, so they really are registries. Same deal: tested October 12, 2026 from outside Iran, so check again from inside.

| Address | /v2/ response | |---|---| | https://docker.1ms.run | 401 | | https://docker.m.daocloud.io | 401 | | https://docker.xuanyuan.me | 401 | | https://dockerproxy.net | 200 |

Normal times: Chinese first, Iranian after, so if the Chinese ones don't answer it falls back:

json@itcorv:~
{
  "registry-mirrors": [
    "https://docker.1ms.run",
    "https://docker.m.daocloud.io",
    "https://docker.arvancloud.ir",
    "https://registry.docker.ir"
  ]
}

Internet shutdown: Iranian only. Drop the Chinese ones so Docker doesn't sit there waiting for them to time out:

json@itcorv:~
{
  "registry-mirrors": [
    "https://docker.arvancloud.ir",
    "https://registry.docker.ir",
    "https://hub.hamdocker.ir"
  ]
}

Don't forget sudo systemctl restart docker after every change.

For containerd, use the same order in hosts.toml. Order matters, it tries hosts from the top:

toml@itcorv:~
# /etc/containerd/certs.d/docker.io/hosts.toml
server = "https://registry-1.docker.io"

[host."https://docker.1ms.run"]
  capabilities = ["pull", "resolve"]

[host."https://docker.m.daocloud.io"]
  capabilities = ["pull", "resolve"]

[host."https://docker.arvancloud.ir"]
  capabilities = ["pull", "resolve"]

During a shutdown, delete the two Chinese hosts and restart containerd.

A few things about the Chinese ones. Lots of them are free, and they can add rate limits or shut down whenever they want. Plenty have come and gone over the last few years. They're also a foreign middleman you don't really know, so for production always pin images by digest. If something changed, the pull fails and you'll know.

Using Kubernetes? hosts.toml

Kubernetes, and anything running directly on containerd, doesn't look at daemon.json at all. containerd wants a separate folder for each registry. First tell it where those folders are. On containerd 1.x:

toml@itcorv:~
# /etc/containerd/config.toml  (containerd 1.x, config version 2)
[plugins."io.containerd.grpc.v1.cri".registry]
  config_path = "/etc/containerd/certs.d"

On 2.x it looks like this:

toml@itcorv:~
# /etc/containerd/config.toml  (containerd 2.x, config version 3)
[plugins.'io.containerd.cri.v1.images'.registry]
  config_path = '/etc/containerd/certs.d'

Then create a hosts.toml for docker.io:

toml@itcorv:~
# /etc/containerd/certs.d/docker.io/hosts.toml
server = "https://registry-1.docker.io"

[host."https://docker.arvancloud.ir"]
  capabilities = ["pull", "resolve"]

Restart and do a pull to see if it works:

bash@itcorv:~
sudo systemctl restart containerd
sudo crictl pull docker.io/library/alpine:3.20

The folder name has to be exactly the registry name, so docker.io. For ghcr.io, make a separate folder with its own hosts.toml. Also, once you set config_path, remove the old registry.mirrors section from config.toml. The two don't play well together.

Your own cache with registry:2

Look, if you have ten servers and each one pulls from outside on its own, it's slow and it wastes bandwidth. Run a registry as a pull-through cache. The first time, it fetches the image from outside and keeps it. After that, it serves it from your own disk.

The config:

yaml@itcorv:~
# /opt/registry/config.yml
version: 0.1
storage:
  filesystem:
    rootdirectory: /var/lib/registry
  delete:
    enabled: true
http:
  addr: :5000
proxy:
  remoteurl: https://docker.arvancloud.ir
  ttl: 168h

And the compose file:

yaml@itcorv:~
# /opt/registry/compose.yml
services:
  registry:
    image: registry:2
    restart: unless-stopped
    ports:
      - "127.0.0.1:5000:5000"
    volumes:
      - ./config.yml:/etc/docker/registry/config.yml:ro
      - ./data:/var/lib/registry

Bring it up and take a look:

bash@itcorv:~
cd /opt/registry && docker compose up -d
curl -s http://127.0.0.1:5000/v2/_catalog

Point remoteurl at something your server can actually reach. Cache server outside Iran? Use https://registry-1.docker.io. Inside? One of the mirrors above. You also need delete.enabled, otherwise the cache never cleans up and your disk fills up. Each instance only caches one upstream, so ghcr.io needs its own instance.

I bound the port to localhost on purpose. Put nginx with TLS in front of it, like I showed in the nginx post. Then on your servers set "registry-mirrors": ["https://mirror.example.com"]. The mirror address has to be the root of the domain. No paths.

Got a team? Harbor

Harbor has a feature called Proxy Cache. You create a Registry Endpoint of type Docker Hub (or point it at an internal mirror), then a project of type Proxy Cache linked to it. Pulls look like this:

bash@itcorv:~
docker pull harbor.example.com/dockerhub-proxy/library/nginx:1.27

Don't forget library for official images. Images you build yourself can live in a private project right next to these, and Trivy scans all of them. Just know Harbor is a lot heavier than registry:2. It runs several services and needs a database. For a single server it's overkill.

A few tips

Builds get stuck too. FROM node:20 in CI is just a pull. If your runner has no mirror, you can write FROM docker.arvancloud.ir/library/node:20-alpine directly, but it's better to set the mirror on the runner itself.

If you get manifest unknown, that tag just isn't on the mirror yet. Try another mirror or another tag.

Don't count on one mirror. Put at least two in there. These things go down without warning.

And remember, a public mirror means you're trusting a middleman. For production, pin images by digest (nginx@sha256:...) so you'll notice if anything changes.

FAQ

I set the mirror but still get a registry-1.docker.io error. Why?

Either you didn't restart Docker or your JSON is broken. Run docker info and see if the mirror shows up.

Does this work for ghcr.io and quay.io?

In Docker, no. registry-mirrors is Docker Hub only. In containerd, yes, as long as you make a separate hosts.toml for each one.

registry:2 or Harbor?

One or a few servers? registry:2. A team with several projects that needs access control and scanning? Harbor.

Are public mirrors safe?

For dev, usually fine. For production your own cache is better, with digests pinned.

So, bottom line. One server? A few mirrors in daemon.json is enough: Chinese first with Iranian behind them in normal times, Iranian only during a shutdown. Cluster? hosts.toml plus one registry:2 in front of everything. Team? Harbor.

If you want to set this up on your own infra together, whether it's a GitLab Runner, a cluster or Harbor, take a look at DevOps services. Or just book a free 30-minute review and we'll go over it.