How to make a mount shared in Docker?
Asked Answered
J

2

14

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?

Juneberry answered 6/7, 2021 at 15:53 Comment(0)
C
59

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
Cranford answered 20/7, 2021 at 13:22 Comment(4)
Thanks a million Colin for your useful fix. I fixed the issue just like what you said. Don't know why it only affects Windows 10 with docker desktop 4.0.0 (67817) but it works on my Mac.Muskogean
I just wanted to chime in that I was having this issue and it had to do with trying to seed my MySQL database with /docker-entrypoint-initdb.d/:ro, which wasn't working anyways to automatically run my database seeds. Removing the /:ro resolved the issue for me.Cheater
@KyleCrossman You could've remove only the trailing / so your configuration would've be /docker-entrypoint-initdb.d:ro. :ro is for read-onlyCranford
just want to report this happening on win10 docker desktop 4.2.0 (70708)Ligon
D
1

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
Doing answered 7/7, 2021 at 10:23 Comment(1)
Thank you for your answer. But this configuration is working on Linux hosts. So the mounting itself will be correct. Otherwise, it would not be possible to start the container(-s) anywhere.Juneberry

© 2022 - 2024 — McMap. All rights reserved.