Creating Docker config.json for external systems
When you are using Docker on your laptop with any kind of registry, there is a very good chance you are using some type of credentials store to keep your registry credentials secure.
In that case, your config.json file looks something like this:
The problem comes when you have to create credentials for your pipeline to push docker images to the private registry or to provide a secret for pulling images for a Kubernetes cluster. As an example of Kubernetes documentation, the file that is expected should contain base64-encoded credentials.
So, you can either craft this file manually or use Docker command line with one extra step of removing credentials helper to allow saving credentials in config.json. To avoid messing up your own config.json, follow these steps:
- Login to your registry by specifying a custom config directory:
2. Remove credsStore line and an extra comma after “auths” block.
3. Run the login command again and you will get a config.json file with base64-encoded credentials ready to be used by external systems.
It’s a simple task that can become annoying easily if you don’t remember the details of Docker authentication setup, so I’ve decided to write this short tutorial as I have to do it from time to time myself.