Docker-compose will fail to build if it cannot access one of the nested folders in the build context. This is actually valid behaviour as the Docker client will return an error as well. Unfortunately, instead of relaying the Docker engine message, docker-compose makes a bad guess at the root cause of the issue.
You can reproduce this issue by creating a Dockerfile, a docker-compose YAML and a build context with nested folders, of which one of them is created using sudo mkdir -p some/nested/path
.
If you now run $ docker build -t A .
it will give you the following error:
Error checking context: 'no permission to read from 'some/nested/path/''.
If you run $ docker-compose build
the error is less comprehensive:
$ docker-compose build
Building A
ERROR: Couldn't connect to Docker daemon. You might need to start Docker for Mac.
The problem is not that Docker for Mac is not running or that docker-compose cannot connect, the problem is that it cannot sent the build context to the Docker daemon because of read permission issue.
How about restarting the terminal?
@keitaj restarting the terminal will not fix this, because the problem is not that docker-compose cannot connect to the Docker daemon. Running docker-compose ps
still works. The build simply fails due to read permission rights problem, which is a valid build termination reason. The problem is that docker-compose shows a generic error message which does not help the end-user.
Thank you for the report!
+1 -- Seconding this issue...
Ran into a similar situation, docker-compose up --build
fails with ... You might need to start Docker for Mac.
, docker images
shows built containers, and am able to manually run docker containers... Turned out one of my repositories had a non-readable file inside of it -- removing this file allows the docker-compose up --build
to succeed.
+1 just encountered this as well - docker-compose version 1.12.0-rc1, build 5e0a793
and Docker version 17.03.0-ce, build 3a232c8
. Changing permissions on the volume mounted by an image to be built by docker-container solved the problem.
@euxneks On Mac OS too?
Nope I am on Ubuntu linux:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.10
DISTRIB_CODENAME=yakkety
DISTRIB_DESCRIPTION="Ubuntu 16.10"
Thank you! For some reason I'm not currently able to reproduce this in my own Ubuntu environment. I'll take a closer look when I have time.
I tried to pin it down for about an hour and it seems like it has something to do with the context given to the docker build process. I was unable to reproduce but it had something to do with a node_modules
directory. In any case, adding node_modules
to your .dockerignore
can also solve this problem for future browsers of this symptom.
(For tracking purposes: looks similar to #4437)
What permissions _does_ it need? It seems I have the same problem, and after reinstalling Docker twice this works with neither the VM or "Docker for Mac"
Edit: I could solve it with
chmod -R a+rX *
Fixed by #5496
Most helpful comment
@keitaj restarting the terminal will not fix this, because the problem is not that docker-compose cannot connect to the Docker daemon. Running
docker-compose ps
still works. The build simply fails due to read permission rights problem, which is a valid build termination reason. The problem is that docker-compose shows a generic error message which does not help the end-user.