Cannot connect to the Docker daemon

So I see this problem when I tried to run a hello-world container

[code language=”shell”]
$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run –help’.
[/code]

Check if the docker is running in the host.
Yes it is running

[code language=”shell”]
$ sudo service docker status
[sudo] password for pandian:
● docker.service – Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-10-12 09:12:03 +08; 18s ago
Docs: https://docs.docker.com
Main PID: 17992 (dockerd)
Tasks: 18
CGroup: /system.slice/docker.service
└─17992 /usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock

Oct 12 09:11:59 docker dockerd[17992]: time=”2019-10-12T09:11:59.472499831+08:00″ level=warning msg=”Your kernel does not support swap memory limit”
Oct 12 09:11:59 docker dockerd[17992]: time=”2019-10-12T09:11:59.472521907+08:00″ level=warning msg=”Your kernel does not support cgroup rt period”
Oct 12 09:11:59 docker dockerd[17992]: time=”2019-10-12T09:11:59.472528459+08:00″ level=warning msg=”Your kernel does not support cgroup rt runtime”
Oct 12 09:11:59 docker dockerd[17992]: time=”2019-10-12T09:11:59.472676228+08:00″ level=info msg=”Loading containers: start.”
Oct 12 09:12:00 docker dockerd[17992]: time=”2019-10-12T09:12:00.302342870+08:00″ level=info msg=”Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option –bip
Oct 12 09:12:00 docker dockerd[17992]: time=”2019-10-12T09:12:00.604326576+08:00″ level=info msg=”Loading containers: done.”
Oct 12 09:12:03 docker dockerd[17992]: time=”2019-10-12T09:12:03.531536271+08:00″ level=info msg=”Docker daemon” commit=a872fc2f86 graphdriver(s)=overlay2 version=19.03.3
Oct 12 09:12:03 docker dockerd[17992]: time=”2019-10-12T09:12:03.535138604+08:00″ level=info msg=”Daemon has completed initialization”
Oct 12 09:12:03 docker dockerd[17992]: time=”2019-10-12T09:12:03.722547518+08:00″ level=info msg=”API listen on /var/run/docker.sock”
Oct 12 09:12:03 docker systemd[1]: Started Docker Application Container Engine.
lines 1-19/19 (END)

[/code]

Docker daemon is running now.

[code language=”shell”]
$ ls -alt /var/run/docker.sock
srw-rw—- 1 root docker 0 Oct 12 09:11 /var/run/docker.sock
[/code]

Run the hello-world now.

[code language=”shell”]
$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[/code]

I captured Kandy lake in Sri Lanka during the summer season of 2019
I captured Kandy lake in Sri Lanka during the summer season of 2019

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top