Failed to pull image: pull access denied for gin-web, repository does not exist or may require 'docker login'

1/8/2019

I have a Docker image gin-web which I have locally and also pushed onto Docker Hub. When in am running my Kubernetes folder i.e.Kubernetes/, I am getting error for my k8s-deployment.yml

Kubernetes\ consist of k8s-deployment.yml and k8s-service.yml Service appears for console.(Using minikube dashboard).

I have referred configured Pod to pull image from Private Registry and added imagePullSecrets to k8-deployment.yml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gin-web # Enter deployment name
  labels:
   app: gin-web
spec:

  replicas: 3 #Enter the number of replicas
  template:
    metadata:
      labels:
        app: gin-web
        tier: service
    spec:
      imagePullSecrets:
      - name: regcred 
      containers:
      - name: gin-web
        image: "gin-web:1.0.1"
        ports:
        - containerPort: 9090
        env:
        - name: PORT
          value: "9090"  

        # define resource requests and limits
        resources:
          requests:
            memory: "64Mi"
            cpu: "125m"
          limits: #k8 automatically restart container when hit with these Limtis
            memory: "128Mi"
            cpu: "250m"

         # check if gin-web is alive and healthy

         #Check if MS recieve traffic from k*
        readinessProbe:
          httpGet:
            path: /ping
            port: 9090
          initialDelaySeconds: 5
          timeoutSeconds: 5
          # check for k8 if container is healthy
        livenessProbe:
          httpGet: 
            path: /ping
            port: 9090
          initialDelaySeconds: 5
          timeoutSeconds: 5

I am getting this error under Deployments in Kubernetes console:

Failed to pull image "gin-web:1.0.1": rpc error: code = Unknown desc = Error response from daemon: pull access denied for gin-web, repository does not exist or may require 'docker login'

-- J Doe
containers
docker
docker-compose
google-cloud-platform
kubernetes

1 Answer

1/8/2019

Looks like you are missing the user or group in the container image string. As far as I can see, nothing in docker hub is just plain gin-web:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gin-web # Enter deployment name
  labels:
   app: gin-web
spec:

  replicas: 3 #Enter the number of replicas
  template:
    metadata:
      labels:
        app: gin-web
        tier: service
    spec:
      imagePullSecrets:
      - name: regcred 
      containers:
      - name: gin-web
        image: "<your-user>/gin-web:1.0.1" <== Add user here
        ports:
        - containerPort: 9090
        env:
        - name: PORT
          value: "9090"  

        # define resource requests and limits
        resources:
          requests:
            memory: "64Mi"
            cpu: "125m"
          limits: #k8 automatically restart container when hit with these Limtis
            memory: "128Mi"
            cpu: "250m"

         # check if gin-web is alive and healthy

         #Check if MS recieve traffic from k*
        readinessProbe:
          httpGet:
            path: /ping
            port: 9090
          initialDelaySeconds: 5
          timeoutSeconds: 5
          # check for k8 if container is healthy
        livenessProbe:
          httpGet: 
            path: /ping
            port: 9090
          initialDelaySeconds: 5
          timeoutSeconds: 5
-- Rico
Source: StackOverflow