2
votes

When I run docker-compose up I get this error:

  Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 71, in main
  File "compose/cli/main.py", line 127, in perform_command
  File "compose/cli/main.py", line 1085, in up
  File "compose/cli/main.py", line 1081, in up
  File "compose/project.py", line 527, in up
  File "compose/service.py", line 360, in ensure_image_exists
  File "compose/service.py", line 1084, in build
  File "site-packages/docker/api/build.py", line 159, in build
  File "site-packages/docker/utils/build.py", line 30, in tar
  File "site-packages/docker/utils/build.py", line 49, in exclude_paths
  File "site-packages/docker/utils/build.py", line 214, in rec_walk
  File "site-packages/docker/utils/build.py", line 214, in rec_walk
  File "site-packages/docker/utils/build.py", line 214, in rec_walk
  File "site-packages/docker/utils/build.py", line 184, in rec_walk
PermissionError: [Errno 13] Permission denied: '/usr/sbin/authserver'
[6560] Failed to execute script docker-compose

and when I run sudo docker-compose up I get this error:

  Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 71, in main
  File "compose/cli/main.py", line 127, in perform_command
  File "compose/cli/main.py", line 1085, in up
  File "compose/cli/main.py", line 1081, in up
  File "compose/project.py", line 527, in up
  File "compose/service.py", line 360, in ensure_image_exists
  File "compose/service.py", line 1084, in build
  File "site-packages/docker/api/build.py", line 159, in build
  File "site-packages/docker/utils/build.py", line 30, in tar
  File "site-packages/docker/utils/build.py", line 49, in exclude_paths
  File "site-packages/docker/utils/build.py", line 214, in rec_walk
  File "site-packages/docker/utils/build.py", line 184, in rec_walk
PermissionError: [Errno 1] Operation not permitted: '/.Spotlight-V100'
[6717] Failed to execute script docker-compose

This is my docker-compose.yml:

version: "3"

services:
  about:
    build: /
    depends_on:
      - "database"
    ports:
      - "3333:3333"

  database:
    image: mongo:latest

and this is my Dockerfile:

FROM node:latest
RUN  mkdir -p /src/app
WORKDIR /src/app
COPY . /src/app
RUN npm install
RUN npm run seed
EXPOSE 3333
CMD ["node", "server/index.js"]

The Dockerfile runs correctly when I create an image and run a container. I would really like to get docker-compose to work though. Will include more code if necessary.

2

2 Answers

3
votes

Your build context refert to the root / of the system that is why you are getting permission denied. it should be relative. try with

version: "3"

services:
  about:
    build: ./
    depends_on:
      - "database"
    ports:
      - "3333:3333"
0
votes

For those with similar problems like "Permission denied" it's related not only with the / instead a ./

docker sends all files in its "build context" that's why this happens to you. @adii is right about the /, as said in the docker documentation:

Warning
Do not use your root directory, /, as the PATH as it causes the build to transfer the entire contents of your hard drive to the Docker daemon.

But take care of the build contexts. I had a similar problem with a folder that was unrelated to the image and I did not understand why the build was complaining. Hope this answer help to understand:

A context is processed recursively. So, a PATH includes any subdirectories and the URL includes the repository and its submodules.

It doesn't care which one have an ADD or a COPY statements. So, put your Dockerfile in a safe place, or make sure that your .dockerignore exclude unnecessary files and folders.
Also, check docker build documentation.