简体   繁体   中英

Removing Docker Kubernetes k8s images from local machine

I had a problem, maybe easy but I couldn't handle this. How to remove all k8s containers and images from local machine?

gcr.io/google_containers/k8s-dns-sidecar-amd64         Up 36 minutes       k8s_sidecar_kube-dns-6fc954457d-mwgvb_kube-system_fd5ebaed-c63c-11e7-b3c8-28d24484a79b_116
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   Up 36 minutes       k8s_dnsmasq_kube-dns-6fc954457d-mwgvb_kube-system_fd5ebaed-c63c-11e7-b3c8-28d24484a79b_116
gcr.io/google_containers/k8s-dns-kube-dns-amd64        Up 36 minutes       k8s_kubedns_kube-dns-6fc954457d-mwgvb_kube-system_fd5ebaed-c63c-11e7-b3c8-28d24484a79b_116
gcr.io/google_containers/kubernetes-dashboard-amd64    Up 36 minutes       k8s_kubernetes-dashboard_kubernetes-dashboard-xpg2v_kube-system_fd403866-c63c-11e7-b3c8-28d24484a79b_222
gcr.io/google-containers/kube-addon-manager            Up 36 minutes       k8s_kube-addon-manager_kube-addon-manager-lenovo-e540_kube-system_9831e93c3188555873fdb49f43198eef_186
gcr.io/google_containers/pause-amd64:3.0               Up 36 minutes       k8s_POD_kube-dns-6fc954457d-mwgvb_kube-system_fd5ebaed-c63c-11e7-b3c8-28d24484a79b_116
gcr.io/google_containers/pause-amd64:3.0               Up 36 minutes       k8s_POD_kube-addon-manager-lenovo-e540_kube-system_9831e93c3188555873fdb49f43198eef_186
gcr.io/google_containers/pause-amd64:3.0               Up 36 minutes       k8s_POD_kubernetes-dashboard-xpg2v_kube-system_fd403866-c63c-11e7-b3c8-28d24484a79b_186

It's unpossible to stop them (they restart always), also to remove them by rm and rmi . Also tryint to kill kubelet .

$ ps ax | grep kubelet
17234 pts/18   S+     0:00 grep --color=auto kubelet

$ kill -KILL 17234
bash: kill: (17234) - No such process

systemctl stop kubelet
Failed to stop kubelet.service: Unit kubelet.service not loaded.

Also trying to force remove this containers: $ docker rm -f $(docker ps -a -q --filter "name=k8s")

but they will recreate after that...

Checking available pods results like this...

$ kubectl get po -n=kube-system
Unable to connect to the server: dial tcp 192.168.99.100:8443: getsockopt: network is unreachable

I was looking for it in documentations, stack etc. but with no effect.

Here's bug on github, but no one could help: https://github.com/kubernetes/kubernetes/issues/61173

Thanks in advance!

Best regards, Marcin

I was working with this guide a half year ago: https://kubernetes.io/docs/getting-started-guides/minikube/ so I guess it using VirtualBox. Maybe you know how I can check this?

@Remario thanks for the tip, now when I execute $ systemctl disable localkube.service and $ systemctl stop localkube.service

I'm able to delete k8s containers and they didn't restart immediately, so we resolve problem partially. Great!

I got this error when trying to execute docker rmi : Error response from daemon: No such image: gcr.io/...

But images are still in docker images list. So I run $ docker system prune -a and all gcr.io images was deleted.

Thanks for your time.

Best regards, Marcin

Something useful

kubectl get deployment nginx-app

NAME         READY   UP-TO-DATE   AVAILABLE   AGE
nginx-app    1/1     1            1           2m

kubectl get po -l run=nginx-app

NAME                         READY     STATUS    RESTARTS   AGE
nginx-app-2883164633-aklf7   1/1       Running   0          2m
kubectl delete deployment nginx-app

deployment "nginx-app" deleted

kubectl get po -l run=nginx-app
# Return nothing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM