Fixing Docker Hub registry HTTP 403 Forbidden error

Published:

So, as of today, the docker corporation in their infinite wisdom, have made the retarded decision to ip block access to their registry.

Here is the message that you get when trying to pull anything:

$ docker pull hello-world
Using default tag: latest
Error response from daemon: error parsing HTTP 403 response body: 
invalid character '<' looking for beginning of value: "<html><body><h1>403 Forbidden</h1>\n
Since Docker is a US company, we must comply with US export control regulations. 
In an effort to comply with these, we now block all IP addresses that are located in Cuba, 
Iran, North Korea, Republic of Crimea, Sudan, and Syria. If you are not in one of these cities, 
countries, or regions and are blocked, please reach out to 
https://hub.docker.com/support/contact/\n</body></html>\n"

Here is a quick solution to that decision:

cat << EOF | sudo tee /etc/docker/daemon.json
{
"registry-mirrors": ["https://mirror.gcr.io"]
}
EOF
sudo systemctl kill --signal=SIGHUP docker

This will overwrite /etc/docker/daemon.json, so if you have any configuration there, you will need to add the registry-mirrors line yourself.

sudo systemctl kill --signal=SIGHUP docker will send SIGHUP signal to the docker daemon, which signals it to reload the configuration file. 1