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

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

Image for post

If you faced an error like in the title when you run docker-compose build, the solutions below may help you.

Is Docker engine running?

Check if Docker engine is running. Docker-compose might not have been able to 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 if the docker Unix socket has correct file ownership. The Unix socket file should be like the following:

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

Is your user in Docker user group ?

You should ensure that your user can access to Docker engine with the current privileges without sudo. It would be a good idea to put your user into docker user group in order to prevent some potential permission/ownership issues that might be occurred. 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.

The build context shouldn?t contain 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?If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable.Building nginx

You should build every service individually to see the actual problem and re-organize the Dockerfile and the build context in order to solve the issue.

18