Skip to main content

Command Palette

Search for a command to run...

Setting Up a Local Docker Mirror

Updated
1 min read
F

I like coding, now it is become my job.

I often do docker build and impulsively did docker system prune -a, which effectively deletes all images and build caches. For some reason, this image, elasticsearch:8.13.4, takes its time to download. I don’t know why, but I know it is not worth trying to fix it.


This problem is not unique:

  1. https://stackoverflow.com/questions/69113444/docker-pull-so-slow

  2. https://github.com/docker/hub-feedback/issues/2172

  3. https://github.com/docker/hub-feedback/issues/2161

  4. https://forums.docker.com/t/docker-pull-taking-forever/130113/2

So I decided to set up my local Docker registry as a mirror. First, I need to spin up the Docker registry image from my Portainer:

After that, for each computer I use at home, update /etc/docker/daemon.json:

{
  "registry-mirrors": ["http://192.168.1.20:32776"]
}

Do not forget to restart docker service sudo systemctl restart docker.

The result is that docker pull almost saturates my network speed. Without this mirror, docker pull often capped at hundreds of kbps despite my 150Mbps downlink.

No alternative text description for this image

Visit this URL to see what images are cached http://<container_addr>/v2/_catalog:

Follow me for updates.

Locally

Part 1 of 1