compose icon indicating copy to clipboard operation
compose copied to clipboard

Docker-compose build fails with nondescript message if a nested folder is not accessible

Open remie opened this issue 9 years ago • 12 comments

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.

remie avatar Feb 10 '17 06:02 remie

How about restarting the terminal?

keitaj avatar Feb 10 '17 09:02 keitaj

@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.

remie avatar Feb 10 '17 10:02 remie

Thank you for the report!

shin- avatar Feb 10 '17 20:02 shin-

+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.

chrrrles avatar Feb 27 '17 08:02 chrrrles

+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.

ghost avatar Mar 21 '17 00:03 ghost

@euxneks On Mac OS too?

shin- avatar Mar 21 '17 00:03 shin-

Nope I am on Ubuntu linux:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.10
DISTRIB_CODENAME=yakkety
DISTRIB_DESCRIPTION="Ubuntu 16.10"

ghost avatar Mar 21 '17 00:03 ghost

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.

shin- avatar Mar 21 '17 00:03 shin-

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.

ghost avatar Mar 21 '17 01:03 ghost

(For tracking purposes: looks similar to #4437)

shin- avatar Mar 28 '17 22:03 shin-

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 *

See Stackoverflow

luckydonald avatar Apr 12 '17 15:04 luckydonald

Fixed by #5496

shin- avatar Feb 13 '18 01:02 shin-