Method 1 – Change docker config default registry
To change the default registry for Docker to a private registry that requires authentication, you can follow these steps:
- Create or edit the
/etc/docker/daemon.json
file on your Docker host machine. - Add the following lines to the file, replacing
your-registry
with the URL of your private registry andyour-username
andyour-password
with your registry credentials:
{
"auths": {
"your-registry": {
"auth": "your-username:your-password"
}
},
"registry-mirrors": ["https://your-registry"]
}
Note that the auths
key is used to specify the credentials for your private registry, and the registry-mirrors
key is used to specify the URL of the registry.
- Save the file and exit.
- Restart the Docker daemon to apply the changes:
$ sudo systemctl restart docker
- Verify that the configuration has been applied by running the
docker info
command. You should see the URL of your registry listed under “Registry Mirrors”.
$ docker info
...
Registry Mirrors:
https://your-registry/
...
With this configuration, Docker will use your private registry as the default registry for pulling images and will authenticate with your registry credentials.
Method 2 – Create a Secret based on existing credentials using in Pod Spec
- https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
- https://docs.gitlab.com/runner/install/kubernetes.html#using-an-image-from-a-private-registry
Method 3 – Create a Secret based on existing credentials using Helm chart
- https://stackoverflow.com/questions/49669077/helm-chart-deployment-and-private-docker-repository
Latest posts by Rajesh Kumar (see all)
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024
Good advice!
Your first method (using the daemon.json) is interesting but does not seem to work as docker crashes after a restart. Are you certain that the auths section is correct?