Create local docker registry and push images to the registry from minikube

Heshani Samarasekara
2 min readJun 4, 2021

--

Recently I was trying minikube kubernetes in my local environment and when I tried to use local docker registry as docker repository, kubenertes was failed to fetch giving the below error.

Warning  Failed     11s   kubelet            Failed to pull image "localhost:5000/hello-world:1.0": rpc error: code = Unknown desc = Error response from daemon: manifest for localhost:5000/hello-world:1.0 not found: manifest unknown: manifest unknown

This article is about the way to solve this issue.

1. Create a plain docker registry

docker run -dit -p 5000:5000 --name registry registry

2. Add the registry to insecure-registries in /etc/docker/daemon.json

{
"insecure-registries": [
"localhost:5000"
]
}

3. Create a docker image locally

4. Tag docker image with the registry name

docker tag hello-world localhost:5000/hello-world

5. Push the image to local registry

docker push localhost:5000/hello-worldUsing default tag: latest
The push refers to repository [localhost:5000/hello-world]
f22b99068db9: Pushed
latest: digest: sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792 size: 525

6. Check the docker image is pushed

curl http://localhost:5000/v2/_catalog
{"repositories":["hello-world"]}

7. Try to use the docker image in minikube kubernetes deployment. You’ll get the above error.

8. Add below yaml file and create a proxy to redirect traffic to 5000.

kubectl create -f kube-registry.yamlkubectl apply -f kube-registry.yamlnohup kubectl port-forward --namespace kube-system $(kubectl get po -n kube-system | grep kube-registry-v0 | \awk '{print $1;}') 5000:5000 &

9. Now try to pull image. It is working.

Reference:

https://hasura.io/blog/sharing-a-local-registry-for-minikube-37c7240d0615/

--

--