Here is a simple pull through cache that will cache container images on the machine that it’s running on so that your Kubernetes nodes don’t reach out to the internet everytime they want to pull images. This is extremely helpful when you have a huge number of Kubernetes nodes and don’t want all of them to blow up your home router.

Or maybe you have realized that those guys offering unlimited internet are actually lying (The cap is 3 TB which is obviously not enough 😉).

I’m using the following registries (you can add your own, just add the new entries):

  1. registry-1.docker.io
  2. registry.k8s.io
  3. quay.io
  4. gcr.io
  5. ghcr.io

You’ll have to tell your nodes to use IP:PORT for the respective registries.

For example, quay would be IP:5002

	version: '3.9'
	services:
	  registry-docker.io:
	    image: registry:2
	    environment:
	      - REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io
	    restart: always
	    container_name: registry-docker.io
	    ports:
	      - "5000:5000"
	  registry-registry.k8s.io:
	    image: registry:2
	    environment:
	      - REGISTRY_PROXY_REMOTEURL=https://registry.k8s.io
	    restart: always
	    container_name: registry-registry.k8s.io
	    ports:
	      - "5001:5000"
	  registry-quay.io:
	    image: registry:2
	    environment:
	      - REGISTRY_PROXY_REMOTEURL=https://quay.io
	    restart: always
	    container_name: registry-quay.io
	    ports:
	      - "5002:5000"
	  registry-gcr.io:
	    image: registry:2
	    environment:
	      - REGISTRY_PROXY_REMOTEURL=https://gcr.io
	    restart: always
	    container_name: registry-gcr.io
	    ports:
	      - "5003:5000"
	  registry-ghcr.io:
	    image: registry:2
	    environment:
	      - REGISTRY_PROXY_REMOTEURL=https://ghcr.io
	    restart: always
	    container_name: registry-ghcr.io
	    ports:
	      - "5004:5000"