Creating Docker config.json for external systems

Maksym Lushpenko | brokee.io
2 min readMar 15, 2021

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:

  1. 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.

--

--

Maksym Lushpenko | brokee.io

Cloud/DevOps/SRE/buzzword engineer :) I enjoy writing about complex problems solved at work or simple tricks that may be useful on a day-to-day work.