...

/

Running the Pod after mounting hostPath

Running the Pod after mounting hostPath

In this lesson, we will create the Pod with mounted Docker socket and play around with Docker

Creating and Testing the Pod

Let’s create the Pod and check whether, this time, we can execute Docker commands from inside the container it’ll create.

Press + to interact
kubectl create \
-f volume/docker.yml

Since the image is already pulled, starting the Pod should be almost instant.

Let’s see whether we can retrieve the list of Docker images.

Press + to interact
kubectl exec -it docker \
-- docker image ls \
--format "{{.Repository}}"

We executed docker image ls command and shortened the output by limiting its formatting only to Repository. The output is as follows.

Press + to interact
docker
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

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 ...

Access this course and 1400+ top-rated courses and projects.