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
1,466 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,890 points

Related Questions In Kubernetes

0 votes
2 answers

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

if u want to directly want to ...READ MORE

answered Jul 26, 2020 in Kubernetes by Akash Gupta
1,318 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
• 7,060 points
877 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,300 points
648 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
• 52,350 points
564 views
+1 vote
1 answer
+2 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,890 points
3,499 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP