Guest User

Untitled

a guest
Jan 16th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. To pull a private DockerHub hosted image from a Kubernetes YAML:
  2.  
  3. Run these commands:
  4.  
  5. ```
  6. DOCKER_REGISTRY_SERVER=docker.io
  7. DOCKER_USER=Type your dockerhub username, same as when you `docker login`
  8. DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
  9. DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
  10.  
  11. kubectl create secret docker-registry myregistrykey \
  12. --docker-server=$DOCKER_REGISTRY_SERVER \
  13. --docker-username=$DOCKER_USER \
  14. --docker-password=$DOCKER_PASSWORD \
  15. --docker-email=$DOCKER_EMAIL
  16. ```
  17.  
  18. If your username on DockerHub is `DOCKER_USER`, and your private repo is called `PRIVATE_REPO_NAME`, and the image you want to pull is tagged as latest, create this `example.yaml` file:
  19.  
  20. ```
  21. apiVersion: v1
  22. kind: Pod
  23. metadata:
  24. name: whatever
  25. spec:
  26. containers:
  27. - name: whatever
  28. image: DOCKER_USER/PRIVATE_REPO_NAME:latest
  29. imagePullPolicy: Always
  30. command: [ "echo", "SUCCESS" ]
  31. imagePullSecrets:
  32. - name: myregistrykey
  33. ```
  34.  
  35. Then run:
  36.  
  37. ```
  38. kubectl create -f example.yaml
  39. ```
Add Comment
Please, Sign In to add comment