67 Running The Pod After Mounting HostPath
67 Running The Pod After Mounting HostPath
67 Running The Pod After Mounting HostPath
In this lesson, we will create the Pod by mounting Docker socket and play around in it.
kubectl create \
-f volume/docker.yml
Since the image is already pulled, starting the Pod should be almost instant.
k8s.gcr.io/kube-proxy
k8s.gcr.io/kube-controller-manager
k8s.gcr.io/kube-scheduler
k8s.gcr.io/kube-apiserver
quay.io/kubernetes-ingress-controller/nginx-ingress-controller
k8s.gcr.io/kube-addon-manager
k8s.gcr.io/coredns
k8s.gcr.io/kubernetes-dashboard-amd64
k8s.gcr.io/etcd
k8s.gcr.io/k8s-dns-sidecar-amd64
k8s.gcr.io/k8s-dns-kube-dns-amd64
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64
k8s.gcr.io/pause
docker
gcr.io/k8s-minikube/storage-provisioner
gcr.io/google_containers/defaultbackend
Even though we executed the docker command inside a container, the output
clearly shows the images from the host. We proved that mounting the Docker
socket ( /var/run/docker.sock ) as a Volume allows communication between
Docker client inside the container, and Docker server running on the host.
slim and efficient base image, and we strongly recommend that you use it
when building your own.
Images like debian , centos , ubuntu , redhat , and similar base images are
often a terrible choice made because of a misunderstanding of how
containers work.
cat Dockerfile
FROM alpine:3.4
MAINTAINER Viktor Farcic <viktor@farcic.com>
EXPOSE 8080
ENV DB db
CMD ["go-demo"]
HEALTHCHECK --interval=10s CMD wget -qO- localhost:8080/demo/hello
vfarcic/go-demo-2
<none>
golang
docker
alpine
gcr.io/google_containers/nginx-ingress-controller
gcr.io/google_containers/k8s-dns-sidecar-amd64
gcr.io/google_containers/k8s-dns-kube-dns-amd64
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64
gcr.io/google_containers/kubernetes-dashboard-amd64
gcr.io/google_containers/kubernetes-dashboard-amd64
gcr.io/google-containers/kube-addon-manager
gcr.io/google_containers/defaultbackend
gcr.io/google_containers/pause-amd64
If we compare this with the previous docker image ls output, we’ll notice
that, this time, a few new images are listed. The golang and alpine images
are used as a basis for each of the build stages. The vfarcic/go-demo-2 is the
result of our build. Finally, <none> is only a left-over of the process and it can
be safely removed.
docker image ls \
--format "{{.Repository}}"
The docker system prune command removes all unused resources. At least, all
those created and unused by Docker. We confirmed that by executing docker
image ls again. This time, we can see the <none> image is gone.
Destroying the Pod #
We’ll destroy the docker Pod and explore other usages of the hostPath
Volume type.
exit
kubectl delete \
-f volume/docker.yml