'Receive mkdir error while trying docker-compose up

I get the following error while trying to compose-up a project.

ERROR: for backend  Cannot start service backend: error while creating mount source path '/private/var/folders': mkdir /private: file exists Encountered errors while bringing up the project.

Can you please advise?

(...)
 backend:
    build:
      context: backend
      dockerfile: Dockerfile
    command: python /app/backend/app/main.py
    ports:
      - 8888:8888
    tty: true
    volumes:
      - ./backend:/app/backend
      - ./.docker/.ipython:/root/.ipython:cached
      - /private/var/folders:/var/folders
    environment:
      PYTHONPATH: .
      MOSEY_ENV: "dev"
    depends_on:
      - "postgres"

(...)

Thank you,



Solution 1:[1]

From your configuration with volumes and the error your are receiving, it seems to me that you have a file' at /private (global path on your computer, not your volume) which is causing the command to return an error.
The second option is that you are using OSX and the /private directory is restricted to the root user. You may have to run the command as sudo.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 michmich112