for-linux icon indicating copy to clipboard operation
for-linux copied to clipboard

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Open fpavlik opened this issue 7 years ago • 97 comments

  • [x] This is a bug report
  • [ ] This is a feature request
  • [x] I searched existing issues before opening this one

Expected behavior

Correct command execution sudo docker info

Actual behavior

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?`

More info

sudo service docker start
A dependency job for docker.service failed. See 'journalctl -xe' for details.

Journal output:

-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is dependency.
Dec 25 08:49:24 REDACTED systemd[1]: docker.service: Job docker.service/start failed with result 'dependenc
Dec 25 08:49:24 REDACTED systemd[1]: containerd.service: Unit entered failed state.
Dec 25 08:49:24 REDACTED systemd[1]: containerd.service: Failed with result 'exit-code'.
Dec 25 08:49:24 REDACTED sudo[10258]: pam_unix(sudo:session): session closed for user root
Dec 25 08:49:24 REDACTED systemd[1]: Stopped Docker Application Container Engine.
-- Subject: Unit docker.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has finished shutting down.
Dec 25 08:50:48 REDACTED sshd[10289]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tt
Dec 25 08:50:49 REDACTED sshd[10289]: Failed password for mail from 200.90.11.218 port 17362 ssh2
Dec 25 08:50:49 REDACTED sshd[10289]: Received disconnect from 200.90.11.218 port 17362:11: Bye Bye [preaut
Dec 25 08:50:49 REDACTED sshd[10289]: Disconnected from 200.90.11.218 port 17362 [preauth]
Dec 25 08:51:10 REDACTED sudo[10292]:       fp : TTY=pts/0 ; PWD=/home/REDACTED ; USER=root ; COMMAND=/bin/journa
Dec 25 08:51:10 REDACTED sudo[10292]: pam_unix(sudo:session): session opened for user root by REDACTED(uid=0)

Output of docker version:

Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:57 2018
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Output of docker info:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Additional environment details (AWS, VirtualBox, physical, etc.) OS info:

Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.5 LTS
Release:	16.04
Codename:	xenial

I'm using VPS

fpavlik avatar Dec 25 '18 09:12 fpavlik

Same problem with the same configuration.

fadeouter avatar Dec 30 '18 16:12 fadeouter

#476

reloxx13 avatar Jan 08 '19 09:01 reloxx13

#476

I tried everything from that issue - nothing helps(((

fpavlik avatar Jan 08 '19 10:01 fpavlik

Can you look at journalctl -fu docker?

cpuguy83 avatar Jan 08 '19 16:01 cpuguy83

as suggestest in the other issue, try to downgrade and better wait for the next version. the previous version works fine, if not sth at your config seems wrong and u need to debug it by reading the logs.

reloxx13 avatar Jan 08 '19 16:01 reloxx13

@cpuguy83

-- Logs begin at Sat 2019-01-05 19:31:08 UTC. --
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Jan 08 10:38:11 185-20-227-19 systemd[1]: Failed to start Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Unit entered failed state.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Jan 08 10:38:11 185-20-227-19 systemd[1]: Stopped Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Start request repeated too quickly.
Jan 08 10:38:11 185-20-227-19 systemd[1]: Failed to start Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Unit entered failed state.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Failed with result 'start-limit-hit'.

fpavlik avatar Jan 08 '19 19:01 fpavlik

Sorry, this does not look like the logs from journalctl -fu docker. Can you confirm the exact command you are running?

cpuguy83 avatar Jan 08 '19 19:01 cpuguy83

@cpuguy83

REDACTED@REDACTED:~$ sudo journalctl -fu docker
[sudo] password for REDACTED: 
-- Logs begin at Mon 2019-01-07 03:12:50 UTC. --
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Jan 08 10:38:11 185-20-227-19 systemd[1]: Failed to start Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Unit entered failed state.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Jan 08 10:38:11 185-20-227-19 systemd[1]: Stopped Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Start request repeated too quickly.
Jan 08 10:38:11 185-20-227-19 systemd[1]: Failed to start Docker Application Container Engine.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Unit entered failed state.
Jan 08 10:38:11 185-20-227-19 systemd[1]: docker.service: Failed with result 'start-limit-hit'.

fpavlik avatar Jan 09 '19 08:01 fpavlik

@fpavlik Ok, seems like this may be the missing .socket file.

cpuguy83 avatar Jan 09 '19 17:01 cpuguy83

@cpuguy83 and what i need to do?

fpavlik avatar Jan 09 '19 18:01 fpavlik

You can either put the socket back in place (18.09.0 incorrectly removed it), here's the file: https://github.com/docker/docker-ce/blob/18.06/components/packaging/deb/systemd/docker.socket

Or you can remove -H fd:// from the docker.service file.

cpuguy83 avatar Jan 09 '19 19:01 cpuguy83

@cpuguy83 at first i copied docker.socket to the /var/run - its not help Next step i tried to find docker.service with the command $ find docker.service - and there is no such file((( where is my mistake?

fpavlik avatar Jan 09 '19 21:01 fpavlik

Should be something like /lib/systemd/system/, but depends on your distro.

cpuguy83 avatar Jan 09 '19 22:01 cpuguy83

Docker 18.09.1 should be available now

thaJeztah avatar Jan 10 '19 02:01 thaJeztah

@cpuguy83 @thaJeztah Oh, i reinstalled docker, now i have 18.09.1, after reinstal it still not works. Next step i found docker.service in /lib/systemd/system and cut -H fd://, then i reload with systemct daemon-reload and nothing helps.

fpavlik avatar Jan 10 '19 12:01 fpavlik

@fpavlik what do systemctl cat docker.service and systemctl cat containerd.service show?

thaJeztah avatar Jan 10 '19 12:01 thaJeztah

@thaJeztah

# /lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate iss
# exists and systemd currently does not support the cgroup feature set r
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in s
# Both the old, and new location are accepted by systemd 229 and up, so 
# to make them work for either version of systemd.

and

# /lib/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
KillMode=process
Delegate=yes
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting 
# in the kernel. We recommend using cgroups to do container-local accoun
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity

[Install]
WantedBy=multi-user.target
lines 1-20/20 (END)

fpavlik avatar Jan 10 '19 12:01 fpavlik

@cpuguy83 in which place i have to put docker.socket?

fpavlik avatar Jan 14 '19 13:01 fpavlik

Well, I'm using Ubuntu 18.04 and it randomly happened with me. I decided to install a newer version of docker following the official guide: https://docs.docker.com/install/linux/docker-ce/ubuntu/

And now it works without even restart the machine.

raphaklaus avatar Mar 18 '19 10:03 raphaklaus

@fpavlik If you install the latest package you should automatically get the docker.socket

seemethere avatar Mar 25 '19 22:03 seemethere