title: Docker on Centos7 : connection refused
body: <p>I know there has been a few questions posted on similar issues already but unfortunately I still can't manage to get the following command working :</p>
  
  <p>$sudo docker run hello-world</p>
  
  <p>Unable to find image 'hello-world:latest' locally
  docker: Error response from daemon: Get <a href="https://registry-1.docker.io/v2/" rel="nofollow noreferrer">https://registry-1.docker.io/v2/</a>: dial tcp 52.54.216.153:443: getsockopt: connection refused.
  See 'docker run --help'.</p>
  
  <p>I am using CentOS7 virtual machine on VirtualBox with HTTP/HTTPS/FTP proxy settings configured at system level. This proxy configuration has been working fine for Chrome and other applications.</p>
  
  <p>After browsing this forum, I tried to create explicit proxy settings for the Docker application by:</p>
  
  <ul>
  <li><p>creating a ~/.docker/config.json file as mentioned at <a href="https://docs.docker.com/network/proxy/" rel="nofollow noreferrer">https://docs.docker.com/network/proxy/</a> and then do "systemctl restart docker"</p></li>
  <li><p>creating a /etc/systemd/system/docker.service.d/http-proxy.conf and then do "systemctl daemon-reload" and "systemctl restart docker"</p></li>
  </ul>
  
  <p>Here is the version of Docker on my virtual machine:</p>
  
  <p>$sudo docker version</p>
  
  <pre><code>Client:
   Version:      18.03.1-ce
   API version:  1.37
   Go version:   go1.9.5
   Git commit:   9ee9f40
   Built:        Thu Apr 26 07:20:16 2018
   OS/Arch:      linux/amd64
   Experimental: false
   Orchestrator: swarm
  
  Server:
   Engine:
    Version:      18.03.1-ce
    API version:  1.37 (minimum version 1.12)
    Go version:   go1.9.5
    Git commit:   9ee9f40
    Built:        Thu Apr 26 07:23:58 2018
    OS/Arch:      linux/amd64
    Experimental: false
  </code></pre>
  
  <p>$curl -v <a href="https://registry-1.docker.io/v2/" rel="nofollow noreferrer">https://registry-1.docker.io/v2/</a></p>
  
  <pre><code>* About to connect() to proxy XXX port 8012 (#0)
  ...
  &gt; 
  &lt; HTTP/1.1 200 Connection established
  &lt; 
  * Proxy replied OK to CONNECT request
  * Initializing NSS with certpath: sql:/etc/pki/nssdb
  *   CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  * Server certificate:
  *   subject: CN=*.docker.io
  *   start date: Aug 02 00:00:00 2017 GMT
  *   expire date: Sep 02 12:00:00 2018 GMT
  *   common name: *.docker.io
  *   issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US
  &gt; GET /v2/ HTTP/1.1
  &gt; User-Agent: curl/7.29.0
  &gt; Host: registry-1.docker.io
  &gt; Accept: */*
  &gt; 
  &lt; HTTP/1.1 401 Unauthorized
  &lt; Content-Type: application/json; charset=utf-8
  &lt; Docker-Distribution-Api-Version: registry/2.0
  &lt; Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io"
  &lt; Date: Fri, 08 Jun 2018 16:00:17 GMT
  &lt; Content-Length: 87
  &lt; Strict-Transport-Security: max-age=31536000
  &lt; 
  {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
  * Connection #0 to host XXX left intact
  </code></pre>
  
  <p>$curl -v <a href="https://54.152.209.167" rel="nofollow noreferrer">https://54.152.209.167</a></p>
  
  <pre><code>   ...
     ...
  &lt; HTTP/1.1 200 Connection established
  &lt; 
  * Proxy replied OK to CONNECT request
  * Initializing NSS with certpath: sql:/etc/pki/nssdb
  *   CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  * Server certificate:
  *   subject: CN=*.docker.io
  *   start date: Aug 02 00:00:00 2017 GMT
  *   expire date: Sep 02 12:00:00 2018 GMT
  *   common name: *.docker.io
  *   issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US
  * NSS error -12276 (SSL_ERROR_BAD_CERT_DOMAIN)
  * Unable to communicate securely with peer: requested domain name does not match the server's certificate.
  * Closing connection 0
  curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.
  </code></pre>