Kubernetes Pod mount /var/run/docker.sock and use imagePullSecrets

7/2/2019

I assign an imagePullSecrets to my pod which allows the pod(?) to pull an image for a container from a private registry:

spec:
  imagePullSecrets:
  - name: dockerrep

This works great. Now in my pod spec I do pass the docker instance down with:

spec:
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock

This way I can use docker inside my container! (I also mount it inside the container). But inside my container the docker instance is not allowed to pull using the imagePullSecrets provided to the pod itself.

Does anyone know if there is a direct way to do this? I thought that the docker instance (that's "passed down") into the container would automatically inherit the "docker login" from the imagePullSecret.

I know I can mount the pull secret manually again inside my container and perform a "docker login", just wanting to know if there is a direct way.

Thanks.

-- Kim
docker
docker-registry
kubernetes

0 Answers