Docker Community Forums

Share and learn in the Docker community.

Cannot "docker run hello-world" (proxy issue?)

Issue type: beginners problems
OS: “Debian GNU/Linux 9.13 (stretch)”
Docker Version: Docker version 19.03.13, build 4484c46

I am running docker on a VM provided by our company’s central IT department which is behind a proxy server. By our IT, the sudo users have set the option env_reset=true in /var/sudoers which I cannot override.

I installed docker following the instructions on https://docs.docker.com/engine/install/ubuntu/, which worked fine up to system check with “docker run hello-world

To start the docker engine, I used sudo systemctl start docker. This creates a docker.sock file in /var/run/.

Next, I tried to run:
$>docker run hello-world
which caused an error

Cannot connect to the Docker daemon at … Is the docker daemon running?

To point to the right docker.sock, added env DOCKER_HOST:
$>env DOCKER_HOST=/var/run/docker.sock docker run hello-world

Which results in:

Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Get hello-world-URL: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See ‘docker run --help’.

I get the same result if I run >sudo docker run hello-word and >sudo -E docker run hello-world.

Following the proposed solution in Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: remote error: tls: handshake failure, I created a http-proxy.conf file in `/etc/systemd/system/docker.service.d with [Service] settings for our companies proxy:

[Service]
Environment="HTTP_PROXY=...our proxy ..."
Environment="HTTPS_PROXY=... our proxy ..."

>sudo systemctl daemon-reload, docker restart…

When I now run

sudo -E env DOCKER_HOST=unix:///var/run/docker.sock docker run hello-world

I get an error message

docker: Error response from daemon: Get URL: proxyconnect tcp: dial tcp 140.181.61.13:3182: connect: connection refused.
See ‘docker run --help’.

I am not sure if this is an error from our proxy which refuses the connection or from the hello-world URL. If I curl the URL directly, I get an “UNAUTHORIZED” error message from the URL.

What can I do?

P.S: I am sorry that I had to cripple the error messages and skip links where I put “URL”, but I am a first time user…

OK, I found the issue: it was a typo in the IP of the http-proxy.conf settings. But to document for others:

  1. installation according to https://docs.docker.com/engine/install/ubuntu/

  2. sudo systemctl start docker will create docker.sock in /var/run/

  3. as normal user always execute >env DOCKER_HOST=unix:///var/run/docker.sock docker ...

  4. create a file /etc/systemd/system/docker.system.d/http-proxy.conf with [Service] HTTP_PROXY HTTPS_PROXY ... entries with CORRECT ports :wink:

  5. create another configuration file ~/.docker/conf.jsonwith entry
    {
    “proxies”:
    {
    “default”:
    {
    “httpProxy”: ,
    “httpsProxy”: ,
    “noProxy”: “localhost,127.0.0.1”
    }
    }
    }

  6. I added all entries of >hosts registry-1.docker.io to /etc/hosts file. I am not sure if this is required.

Then env DOCKER_HOST=unix:///var/run/docker.sock docker run hello-world worked for me.

1 Like