skip to Main Content

I want to run a container using my image, hosted in Docker Hub registry. I have this deployment:

// ---
spec:
  containers:
  - name: web
    image: "mycompany/myimage:1.0"
    imagePullPolicy: IfNotPresent
  - name: db
    image: postgres:13
  imagePullSecrets:
  - name: dockerhub-secret
// ---

Then, I have the secret dockerhub-secret:

apiVersion: v1
kind: Secret
metadata:
  name: dockerhub-secret
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: <my-base64>

But I get this timeout error:

Failed to pull image "mycompany/myimage:1.0": rpc error: code = DeadlineExceeded desc = failed to pull and unpack image "docker.io/mycompany/myimage:1.0": failed to resolve reference "docker.io/mycompany/myimage:1.0": failed to do request: Head "https://registry-1.docker.io/v2/mycompany/myimage/manifests/1.0": dial tcp 54.196.99.49:443: i/o timeout

Postgres image is pulled with no errors.

My image is pulled with no errors in my local machine:

docker pull mycompany/myimage:1.0

I tried to use wrong credentials, on purpose, in the Kubernetes secret but the same error happens.

2

Answers


  1. Chosen as BEST ANSWER

    Solved. Subnet where cluster lives had no Internet access. I configured SNAT and everything is working now.

    For some reason, postgres docker image was being downloaded. I suppose something related to cache, who knows.


  2. Check that deployment and secret are on the same namespace. If the service account you are using is default, you have to patch it to read image pull secrets:

    kubectl patch serviceaccount default -n <namespace> -p '{"imagePullSecrets": [{"name": "dockerhub-secret"}]}'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search