How to make a mount shared in Docker?

Viewed 11666

I'm trying to start a project in Docker (directly from the Debian distro) in Windows 10 and getting this error:

$ docker compose up -d
[+] Running 0/0
 ⠋ Container core_php74_1  Creating                                                                                                                            0.0s
Error response from daemon: path /home/me/path/to/project is mounted on / but it is not a shared mount.

How to make the mounted path /home/me/path/to/project a shared mount?

2 Answers

I got the same error after updating docker for desktop to 3.5.2 (66501). I have created volumes with trailing slashes in my docker-compose.yml. I removed them to fix the problem.

Change

volumes:
  - ./:/app/
  - ./another/folder:/folder/

To

volumes:
  - ./:/app
  - ./another/folder:/folder

You can NOT mount into docker to "/" In your docker-compose.yml must be this lines or similar for windows :

volumes:
  - /home/me/path/to/project:/path/in/image
Related