Created
March 5, 2018 15:17
-
-
Save xterat/02170fcc7bb08db382367a3a4d370f5f to your computer and use it in GitHub Desktop.
Revisions
-
xterat created this gist
Mar 5, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # Use docker behind proxy > 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](https://docs.docker.com/v1.13/engine/admin/systemd/#http-proxy) to this problem. 1. Create a systemd drop-in directory for the docker service: ```Bash $ mkdir -p /etc/systemd/system/docker.service.d ``` 2. Create a file called `/etc/systemd/system/docker.service.d/http-proxy.conf` that adds the `HTTP_PROXY` environment variable: ```Bash [Service] Environment="HTTP_PROXY=http://proxy.example.com:80/" ``` 3. If you have internal Docker registries that you need to contact without proxying you can specify them via the `NO_PROXY` environment variable: ```Bash Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com" ``` 4. Flush changes: ```Bash $ sudo systemctl daemon-reload ``` 5. Verify that the configuration has been loaded: ```Bash $ systemctl show --property=Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/ ``` 6. Restart Docker: ```Bash $ sudo systemctl restart docker ```