less than 1 minute read

Setup a local Docker registry for your development to be used by k8s Docker.

Environment:

Component Version Note
Docker Desktop 4.31.0 Docker desktop running on my laptop
k8s 1.29.2 Kubernetes in Docker Desktop

Step 1: Start a registry

Start a registry using Docker:

docker run -d --name registry \
    -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
    -p 5000:5000 registry:2

The command starts a local registry without HTTPS. That’s intentional for development purpose. But that’s also where you could have issues: k8s from Docker uses HTTPS to retrieve images from the registry.

Step 2: Setup Docker

From k8s in Docker, the registry is available on host.internal.docker:5000 without HTTPS. We have to tell Docker that this registry is unsecure.

Open the file ~/.docker/daemon.json (this path is for mac, check for your OS) and define the registry as unsecure: add this line:

{
    "insecure-registries": ["host.docker.internal:5000"]    
}

Restart Docker. Your k8s instance in Docker can now retrieve your images form your local registry.

Enjoy!