Accessing private Docker Hub repository from Kubernetes on Vagrant

0 votes

I am using kubernetes 1.2.0. I am trying to pull image from my docker hub repo into my local kubernetes on vagrant:

Container "hellonode" in pod "hellonode-n1hox" is waiting to start: image can't be pulled

Failed to pull image "username/hellonode": Error: image username/hellonode:latest not found

I am using kubernetes locally on my vagrant machine and created a secret named "dockerhub". i supply this secret as the image pull secret.

Sep 18, 2018 in Kubernetes by Atul
• 10,240 points
203 views

1 answer to this question.

0 votes

In order to pull private dockerhub hosted images using kubernetes yaml use:

DOCKER_REGISTRY_SERVER=docker.io
DOCKER_USER=Type your dockerhub username, same as when you `docker login`
DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`

kubectl create secret docker-registry myregistrykey \
  --docker-server=$DOCKER_REGISTRY_SERVER \
  --docker-username=$DOCKER_USER \
  --docker-password=$DOCKER_PASSWORD \
  --docker-email=$DOCKER_EMAIL

This is what your yaml file should look like:

apiVersion: v1
kind: Pod
metadata:
  name: whatever
spec:
  containers:
    - name: whatever
      image: DOCKER_USER/PRIVATE_REPO_NAME:latest
      imagePullPolicy: Always
      command: [ "echo", "SUCCESS" ]
  imagePullSecrets:
    - name: myregistrykey

Then execute:

kubectl create -f example.yaml
answered Sep 18, 2018 by DareDev
• 6,810 points

Related Questions In Kubernetes

0 votes
1 answer

How can I access a service installed on Kubernetes from anywhere?

I have followed the link which you have ...READ MORE

answered Jul 23, 2018 in Kubernetes by Atul
• 10,240 points
141 views
0 votes
2 answers

run private docker images on Google Container Engine

run docker login on minions before starting.  ...READ MORE

answered Aug 30, 2018 in Kubernetes by Nilesh
• 6,880 points
34 views
0 votes
1 answer

Accessing remote kubernetes cluster on azure using kubectl

So, try this. Edit your kube config ...READ MORE

answered Sep 11, 2018 in Kubernetes by ajs3033
• 7,280 points
59 views
0 votes
1 answer

nnot set docker credentials on kubernetes AWS

The best method for you is ImagePullSecrets - you ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 41,660 points
37 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Cannot connect unix:///var/run/docker.sock in kubernetes using GitLab CI runner

Do not use this: DOCKER_DRIVER: overlay because OVERLAY is ...READ MORE

answered Oct 16, 2018 in Kubernetes by DareDev
• 6,810 points
894 views