Docker uses a configuration file, config.json, for unencrypted storage of credentials. The docker error loading config file triggers due to a number of reasons including an empty config file.
As a part of our docker hosting support, we help our Customers to fix similar docker related errors regularly.
Let us today discuss the possible causes and fixes for this error.
What are the causes for docker error loading config file?
As we discussed earlier, the config.json file in docker stores the unencrypted credentials. Thus during docker installation, while we use docker CLI using sudo before adding the user to the docker group, we might encounter an error message, telling that ~/.docker/
directory was created with incorrect permissions:
WARNING: Error loading config file: /home/user/.docker/config.json -
stat /home/user/.docker/config.json: permission denied
Let us now look at the fixes for this error message.
How to fix docker error loading config file
Changing the ownership and permissions using the following commands can fix the permission issue with the configuration file.
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
$ sudo chmod g+rwx "/home/$USER/.docker" -R
Another common solution is to remove the ~/.docker/
directory. This removes the directory created with wrong permissions and will help to fix the issue. However, if we remove the directory, it re-generates automatically when we rerun Docker. Thus it removes any custom settings in the config file during the deletion of the configuration file.
Apart from the fixes above, adding an empty json object {} to the file can fix the error loading config file when the configuration file is empty
[Need any further assistance in fixing Docker errors? – We’re available 24*7]
Conclusion
In short, the error loading config file triggers due to reasons like an empty config file or permission issue with the configuration file. Today, we saw how our Support Engineers fix this error.
0 Comments