If you faced an issue like “Couldn’t connect to Docker daemon at http+docker://localunixsocket — is it running?”…

İbrahim Gündüz
Dec 21, 2017 · 2 min read

If you faced the error when you run docker-compose build you should check the followings:

Is the docker engine running?

Check whether docker engine service running or not. Docker-compose maybe can’t access to docker engine.

$ sudo service docker status
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-12-21 19:16:26 UTC; 1h 45min ago
Docs: https://docs.docker.com
Main PID: 20127 (dockerd)
Tasks: 23
Memory: 1.0G
CPU: 53.520s

Is the unix socket file of docker has proper ownership ?

Check the unix socket file of docker whether it has correct owner or not.

$ sudo ls -la /var/run/docker.sock
srw-rw---- 1 root docker 0 Dec 21 19:16 /var/run/docker.sock

Is your user in docker user group ?

You need to use sudo if your user is not in docker user group. Even you used sudo, you may encounter other permission issues between host and container filesystems when you mounted volume to containers. You can add your user to docker user group with the following command.

$ sudo usermod -aG docker ${USER}

You should logout and login the host again, after called the command.

Do you have any volume that contains some files with different ownership which docker can’t access.

Your build context shouldn’t be contains any mounted volume that contains some files with different ownership which docker can’t access. Otherwise you may have some permission issues between host and container filesystems while docker checking context.

$ docker-compose -f deploy/docker/docker-compose.yml build --build-arg UID=$(id -u)
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

You should re-organize your Dockerfile files and fix build context of each service which is defined in docker-compose.yml

İbrahim Gündüz

Written by

Nothing more than developer. Linkedin: https://www.linkedin.com/in/ibrahimgunduz Github: http://github.com/ibrahimgunduz34/