Docker Community Forums

Share and learn in the Docker community.

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Soooo for running docker in docker, on windows 10. Powershell is run as admin. I have a manager and a worker up

the compose yaml file is as such:

version: '2’
services:
manager:
image: docker:latest
ports:
- “2375”
- "8080"
privileged: true
tty: true
worker:
image: docker:latest
ports:
- "8080"
privileged: true
tty: true

i dont know why or what tty: true even does but its the only way to get it to stay up for some reason.

i try to init the manager with:

docker-compose exec manager docker swarm init
–listen-addr 0.0.0.0:2377

also tried with the port being 0.0.0.0:2375 as what is open in the compose yaml.

when i run the command

and get this:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

here is the result of a docker-compose ps

   Name                   Command           State                        Ports

swarmtest_manager_1 docker-entrypoint.sh sh Up 0.0.0.0:32782->2375/tcp, 0.0.0.0:32781->8080/tcp
swarmtest_worker_1 docker-entrypoint.sh sh Up 0.0.0.0:32780->8080/tcp

Please help! Running and testing services in the docker in docker environment woudl be ideal, although i still dont like compose as i am trying to learn how to use it better, creating a docker-machine and using the docker swarm mode seems much easier. But i am still a docker noob.

I ran into this error message when I was trying to use a distribution of Docker installed via Homebrew on Mac OS. Reinstalling Docker from the official Docker site resolved this for me.

1 Like

Hi,
I am getting following error. Can anybody help me out ?

“Cannot connect to the Docker daemon. Is the docker daemon running on this host?”

my docker daemon is getting failed to start, when ever I restart the laptop
I have ubuntu16.04 xenial distrubution and docker v17.03,
I have tried to reinstalled docker but still that didn’t work

 sudo service docker stop 

   sudo service docker start 

(this thing fixes till the system is on )

but again when i restart or switch on/off the system it fails to start …

Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket firewalld.service
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

this is the docker.service in lib/systemd/system

This was the fix for me!

This work’s, Thanks…

Once the above configuration has been configured, Jenkins work’s fine for docker build. But when i try to run docker commands manually in that Machine i am unable to get response for manually typed docker commands.

Is this normal ?

usermode -aG docker gitlab-runner

solved the problem! This work for me. Lots of thank you.

Hi Rodney,

Once the above configuration has been configured, Jenkins work’s fine for docker build. But when i try to run docker commands manually in that Machine i am unable to get response for manually typed docker commands.

Did you faced this issue after this configuration.

No. Do you have sudo privileges?

Thanks! That’s the fix for me too. I wish this were mentioned somewhere in the tutorial.

Greetings, I am no expert here, but I ran into some trouble after following this advice and issuing this command:
sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &

Have a look at this link:

I ended up with monero mining containers running on my server and auto spawning…

Heads up!

1 Like

I ran into some trouble using 0.0.0.0:2375
see:

Heads Up!

Happens with me too, found any solution?

Yes Parthmodi, I have kept my configuration as mentioned below in both the files,

/lib/systemd/system/docker.service

[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=infinity

/etc/init.d/docker

DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
#DOCKER_OPTS="-H tcp://0.0.0.0:2375"
DOCKER_DESC=“Docker”

And Kept the docker host as an empty in Jenkins job, so that it by default uses the local docker for build purpose.

Above change made everything normal.

thanks it solved the problem !!

Thanks, this was my problem

Hi. sorry I have same probem.
I follow your sugest but not working for me. please?

Operating System: Ubuntu 16.04.5 LTS
Docker Server Version: 18.06.0-ce

I tried all of these suggestions and none of them worked. Completely uninstalling and reinstalling docker worked, but immediately stopped working after a reboot. I ended up finding a temporary workaround where I can run:

sudo dockerd

in another terminal and then all my docker commands work. I consider that a temporary fix for now, but thought that could help someone out.

1 Like

You can try out this :

systemctl start docker

This work for me.

1 Like