Compose: Be more specific than "ERROR: Couldn't connect to Docker daemon"

Created on 27 Oct 2017  ยท  7Comments  ยท  Source: docker/compose

Context: a simple docker-compose file, which builds a local Dockerfile. One of the file in the context is not readable by the current user.

With docker-compose build:

philippe@pv-desktop:~/work/stvs/mediawiki$ docker-compose build
Building web
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.

philippe@pv-desktop:~/work/stvs/mediawiki$ docker-compose --verbose build
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.auth.find_config_file: Trying paths: ['/home/philippe/.docker/config.json', '/home/philippe/.dockercfg']
docker.auth.find_config_file: Found file at path: /home/philippe/.docker/config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Found entry (registry=u'https://index.docker.io/v1/', username=u'silex')
compose.cli.command.get_client: docker-compose version 1.16.1, build 6d1ac21
docker-py version: 2.5.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t  3 May 2016
compose.cli.command.get_client: Docker base_url: http+docker://localunixsocket
compose.cli.command.get_client: Docker version: KernelVersion=4.4.0-97-generic, Arch=amd64, BuildTime=2017-09-26T22:40:56.000000000+00:00, ApiVersion=1.32, Version=17.09.0-ce, MinAPIVersion=1.12, GitCommit=afdb6d4, Os=linux, GoVersion=go1.8.3
compose.service.build: Building web
compose.cli.verbose_proxy.proxy_callable: docker build <- (nocache=False, pull=False, cache_from=None, target=None, stream=True, labels=None, network_mode=None, tag=u'mediawiki_web', buildargs={}, forcerm=False, rm=True, path='/home/philippe/work/stvs/mediawiki', dockerfile=None)
docker.api.build._set_auth_headers: Looking for auth config
docker.api.build._set_auth_headers: Sending auth config (u'https://index.docker.io/v1/')
ERROR: compose.cli.errors.exit_with_error: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.

With docker build:

philippe@pv-desktop:~/work/stvs/mediawiki$ docker build -t mediawiki_web .
error checking context: 'no permission to read from '/home/philippe/work/stvs/mediawiki/data/mysql/ca-key.pem''.

philippe@pv-desktop:~/work/stvs/mediawiki$ sudo ls -alh /home/philippe/work/stvs/mediawiki/data/mysql/ca-key.pem
-rw------- 1 999 docker 1.7K Oct 12 14:05 /home/philippe/work/stvs/mediawiki/data/mysql/ca-key.pem

As you can see, it's very hard to get the real error with docker-compose. As soon as I use docker build we see that the problem is access to a specific file. Why doesn't docker-compose build report the same error as docker build?

This is probably somewhat related to #4386.

Most helpful comment

I think it's a docker permission issue.

sudo /usr/local/bin/docker-compose build // maybe you should use this.

All 7 comments

Up. Yes i have the same issue, my Dockerfile does'nt compile until i'll put it in an empty folder. Before that she was sharing place with private folder.

Error in compose : Couldn't connect to Docker daemon - you might need to run docker-machine start default.
Error with docker : error checking context: 'no permission to read from '/data/ca-key.pem''.

Thanks

I agree that the error sould be more specific in case of building an image via docker-compose In my case the error had to do with wrong files permissions in building context

With docker-compose

โฏ docker-compose build

> Building app
> ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
 ```
With **docker**

โฏ docker image build -f docker/app/Dockerfile .

error checking context: 'no permission to read from
'/home/user/path/to/storage/oauth-public.key''.
```

:+1:

I think it's a docker permission issue.

sudo /usr/local/bin/docker-compose build // maybe you should use this.

Try running with root:
sudo docker-compose build

I am still having this issue. To double check if this issue is happening to you (and it is not an actual connection problem to your docker daemon) just run another docker command like docker ps if it works you are probably having this issue, the solution for me was just to grant permission to the files docker can't access, you can check those files when you run docker build, or you could just change the permission to all the files in the current folder:
chmod 755 -R *

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DhairyashilBhosale picture DhairyashilBhosale  ยท  3Comments

Hendrik-H picture Hendrik-H  ยท  3Comments

dimsav picture dimsav  ยท  3Comments

saulshanabrook picture saulshanabrook  ยท  3Comments

AvdN picture AvdN  ยท  3Comments