docker ignores daemon.json file

Viewed 887

I'm trying to add a mirror to my docker in order to use my server to cache images from docker hub using the following syntax: /etc/docker/daemon.json

{
 "registry-mirrors": ["https://myserver.com"]
}

I have seen the above config even docker's official documentation. but my ubuntu 20.04 does not read that file at all. Even if I restart the docker service.

2 Answers

You should rewrite the configuration file as follow:

{
 "registry-mirrors": ["myserver.com"]
}

Remove the protocol!

Intro

Added a directive to daemon.json which was just being ignored when I restarted Docker. Docker was restarting without error, it was just ignoring my change.

Problem

I was attempting to change the default log target to syslog from json-file by APPENDING the log-driver directive to the end of /etc/docker/daemon.json (I was scripting my Docker install and so was building this file incrementally).

But no matter WHAT I did, I could not get the change read. The output of docker info --format '{{.LoggingDriver}}' was always json-file.

Troubleshooting

Investigated the potential of a formatting error like the accepted answer, but this bore no fruit. Reading, re-reading of the Docker docs. Googling. Nothing could clear the error.

Solution

The Problem? Looks like Docker was really finicky about the ORDER the logging directive "log-driver" appeared. After wasting hours and beating my brains in, I changed the order the directive appeared in the file by PREPENDING it to the top of daemon.json like so:

{
  "log-driver": "syslog",
  "default-address-pools":
  [
    {"base":"192.168.X.X/24","size":28}
  ]
}

With the directive at the TOP, the change was recognized after restarting Docker and the output of docker info --format '{{.LoggingDriver}}' was now as expected: syslog. Go figure...

Conclusion

It was a silly problem, but wow did it waste some cycles figuring out how things were broken. Hope this get folks like myself out of a hole who couldn't find this solution Googling-

Related