3

I have installed docker in my machine following the official installation steps for ubuntu. At the verification steps it fails.

When I run the command: docker run hello-world it throws following error message:

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

Below are the docker details for my machine.

Client: Docker Engine - Community
Version:           19.03.6
API version:       1.40
Go version:        go1.12.16
Git commit:        369ce74a3c
Built:             Thu Feb 13 01:27:49 2020
OS/Arch:           linux/amd64
Experimental:      false
Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix 
/var/run/docker.sock: connect: permission denied

If I tried for docker info I got the following message:

Client: Debug Mode: false

Server: ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info: dial unix /var/run/docker.sock: connect: permission denied errors pretty printing info

2
  • Your current user is not in the docker group and hence does not have necessary permissions to communicate with the docker daemon => sudo usermod -a -G docker yourUserName Commented Apr 13, 2020 at 8:31
  • 1
    On Ubuntu 20.4, a system restart fixed the issue and I was able to see output. Commented May 16, 2022 at 16:21

6 Answers 6

8

You can simply pull and test it in this way:

$ sudo docker pull hello-world
$ sudo docker run hello-world
3

First check if docker is running using

sudo service docker status

If its running, then you probably missed out adding your user to docker group. To confirm this, try docker commands with sudo

If you don't want to use sudo every time follow below guide to add you user to docker group

Step 2 — Executing the Docker Command Without Sudo (Optional)

NOTE : You can not run Docker in WSL i.e Ubuntu on Windows, so you need to install docker for windows, following guide provided complete steps of using Docker in WSL.

Setting Up Docker for Windows and WSL to Work Flawlessly

2
  • Not sure if WSL or Docker were updated, but I have had success with running docker inside WSL by simply using this guide docs.docker.com/engine/install/ubuntu Docker is not installed on my windows 11 machine.
    – devaent
    Commented Nov 11, 2023 at 16:51
  • Windows 11 is more flexible when it comes to supporting linux based products, so it is higly possible this answer is valid only till Windows 10.
    – Aditya T
    Commented Nov 16, 2023 at 4:18
0

Post installation steps of docker are probably not executed. Basically, the current logged in used need to be added to docker group.

Just follow the instructions here from docker documentation - https://docs.docker.com/engine/install/linux-postinstall/

FYA- group membership evaluation would happen only after a reboot of ubuntu (in 18.04). So, after following the above link, reboot ubuntu machine. Then try docker images and permission issue reported should get resolved.

0

This problem has solved when I upgrade my ubuntu 19.04 to 19.10 and then reinstall it.

0

I had similar problem, while trying to fix the below error,

root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 10.187.215.112:53: read udp 10.187.215.103:58777->10.187.215.112:53: read: connection refused.

So, The error was due to the proxy in my enterprise setup, the daemon requests are refused via proxy

WRONG TRY to fix it, ( which caused error like above.) I have added the registry-1.docker.io ip to the /etc/hosts, but it caused the similar error as in this StackOverflow here.

root@neno88:/home/mohan# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'. root@neno88:/home/mohan#

CORRECT STEPS: How to fix it,

  1. Just add your Proxy details to the /etc/systemd/system/docker.service.d/proxy.conf (folder docker.service.d may not exists , so create the directory before)
  2. After adding the proxy details check using the below commands , whether the daemon successfully see/read your environment variables.

$ sudo systemctl daemon-reload

$ sudo systemctl restart docker

$ systemctl show --property=Environment docker

Refer this doc: https://www.serverlab.ca/tutorials/containers/docker/how-to-set-the-proxy-for-docker-on-ubuntu/

0

In my case disconnecting from VPN solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.