Minikube manage docker images
Minikube
Minikube is a tool that make it easily to run Kubernetes locally. Installing minikube is very naturally for MacOS.
After install minikube, we can check minikube status
> minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
We also can list default minikube pods
> kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-66bff467f8-lnt67 1/1 Running 0 10d
etcd-minikube 1/1 Running 0 10d
kube-apiserver-minikube 1/1 Running 0 10d
kube-controller-manager-minikube 1/1 Running 0 10d
kube-proxy-pqg98 1/1 Running 0 10d
kube-scheduler-minikube 1/1 Running 0 10d
storage-provisioner 1/1 Running 0 10d
Create a nginx pod
Let’s create a nginx service quickly
kubectl run --generator=run-pod/v1 web --image=nginx --labels app=web --expose --port 80
The web microservice has been created
> kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
default web 1/1 Running 0 27s
Delete the nginx pod, the docker image is gone?
Let’s delete a the nginx pod
kubectl delete pod web
In order to check container images, we need to use the following command
minikube ssh
docker@minikube:~$
When we list all docker images, we observe the nginx image is still cached
docker@minikube:~$ docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 7e4d58f0e5f3 39 hours ago 133MB
Conclusion
Minikube is a good tool to do a proof of concept locally. However, we still want to clean up docker images cached by minikube, to save more resources locally.
docker@minikube:~$ docker rmi 7e4d58f0e5f3
Untagged: nginx:latest
Untagged: nginx@sha256:9a1f8ed9e2273e8b3bbcd2e200024adac624c2e5c9b1d420988809f5c0c41a5e
Deleted: sha256:7e4d58f0e5f3b60077e9a5d96b4be1b974b5a484f54f9393000a99f3b6816e3d
Deleted: sha256:eedfd37abc0b05520a719addf6675b372687fe9a2ed1746fa988335720d4376c
Deleted: sha256:4f052ddd517f6dc5b74d2f7d881838b8ec6a5e67ec7a1da8bbbe91e1e068ad3a
Deleted: sha256:5f78154d356577280e4ac0d9bf0d021d488828e57f953b011dcbadaecd539ce4
Deleted: sha256:db5783668220e16186080f3e9d69ad748aab8c72abb8e457f6fc45369461634b
Deleted: sha256:07cab433985205f29909739f511777a810f4a9aff486355b71308bb654cdc868