We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
To use images from a private repository on hub.docker.com, you need to add a secret containing the credentials for accessing that repository. This can be done via the kubectl
command:
$ kubectl create secret docker-registry <my-secret-name> \
--docker-server=docker.io \
--docker-username=<your-docker-username> \
--docker-password=<your-docker-password> \
--docker-email=<your-docker-email>
If the secret already exists and you want to update it, you first need to delete it:
$ kubectl delete secret <my-secret-name>
When you then define a deployment, you can use the imagePullSecrets
option in the deployment yaml to indicate which secret needs to be used to grab the docker image:
my-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
labels:
app: my-deployment
spec:
replicas: 1
selector:
matchLabels:
app: my-deployment
template:
metadata:
labels:
app: my-deployment
spec:
containers:
- name: my-deployment
image: <my-docker-user>/<my-docker-private-repo<
imagePullSecrets:
- name: <my-secret-name>
The deployment can then be done using the apply
command:
$ kubectl apply -f my-deployment.yaml
You can read many more details about this on the kubernetes.io website.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.