Docker - Set HTTP/HTTPS proxy

By xngo on October 1, 2019


After I installed Docker, I test run it and it is showing me the following error message:

/media/master/github>docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get x509: certificate is valid for, not
See 'docker run --help'.


I got the error because I'm behind a proxy server. Therefore, to resolve this issue, I set the proxy configurations in Docker as follows.

  1. Create a systemd drop-in directory for the docker service:
$ mkdir -p /etc/systemd/system/docker.service.d
  1. Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf and add the HTTP_PROXY environment variable:
  1. Restart Docker:
systemctl daemon-reload
systemctl restart docker
  1. Verify that the configuration has been loaded:
$ systemctl show --property=Environment docker
  1. Test run Docker: Docker - Run hello-world - Output

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.