Reputation: 1097
I'm using Docker Destop as a local kubernetes provider. I'm tired to reinstall a few additional tools to my default alpine Docker image, so I generated a new one from Docker in order to hold every tool which I will need to debug my pods. Now I would like to use kubectl to debug my pod like this:
kubectl debug -it foo --image=my-local-docker-image
Yet an error appears:
Warning: container debugger-jzwng: Error response from daemon: failed to resolve reference "docker.io/library/custom-alpine:latest": failed to do request: Head "https://registry-1.docker.io/v2/library/custom-alpine/manifests/latest": dialing registry-1.docker.io:443 container via direct connection because static system has no HTTPS proxy: connecting to registry-1.docker.io:443: dial tcp: lookup registry-1.docker.io: no such host
What can I do so that kubectl looks for my docker image locally? Im using Windows 11 + Docker Desktop Personal Edition
(Forgot to add, her's my single pod.yaml used for my k8s cluster):
apiVersion: v1
kind: Pod
metadata:
name: foo
spec:
containers:
- name: app
image: nginx:alpine
ports:
- containerPort: 80
resources:
limits:
memory: "256Mi"
- name: sidecar
image: curlimages/curl:8.3.0
command: ["/bin/sleep", "3650d"]
resources:
limits:
memory: "128Mi"
Upvotes: 0
Views: 71
Reputation: 1097
I crafted a solution inspired by a similar problem at How to use Local docker image in kubernetes via kubectl:
I must run a docker registry image locally as follows:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
The I must re-create my image with a new name:
docker build . -t localhost:5000/custom-alpine
To make this locally available to kubectl, push the image to the local docker registry:
docker push localhost:5000/custom-alpine
Now I can use the docker image from kubectl locally:
kubectl debug -it foo --image=localhost:5000/custom-alpine
Upvotes: 0