When I run
docker run hello-world
, I get error message "docker: Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid.". Here is the solution to this problem.
-
Create a systemd drop-in directory for the docker service:
$ mkdir -p /etc/systemd/system/docker.service.d
-
Create a file called
/etc/systemd/system/docker.service.d/http-proxy.conf
that adds theHTTP_PROXY
environment variable:[Service] Environment="HTTP_PROXY=http://proxy.example.com:80/"
-
If you have internal Docker registries that you need to contact without proxying you can specify them via the
NO_PROXY
environment variable:Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"
-
Flush changes:
$ sudo systemctl daemon-reload
-
Verify that the configuration has been loaded:
$ systemctl show --property=Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/
-
Restart Docker:
$ sudo systemctl restart docker