Mongodb + compose with volumes, data not persisted

I’m using 1.11.1 - beta 13.1 docker on Mac.

My compose file contains this:

build: ./service
restart: always
- "4000:4000"
- db:apidb
image: mongo:latest
restart: always
- /data/db:/data/db

I can docker-compose up and use the api to persist data in the linked mongodb container. Can then stop it and up it again, and the data is still there.

However, if I restart the host OS, and then up the containers again with compose, the data is gone.

I must be missing something pretty basic, but for the love of me I can’t seem to figure out what. All articles online refer to issues with docker and volumes, but those are supposed to related to the virtualbox dependency which is now gone.

Hi Ramon,

You are experiencing an unfortunate rough edge in our current file system sharing solution. In particular, only /Volumes, /Users, /tmp, and /private are directly accessible to be bind mounted. If you need to bind mount another path, you have to prefix it with /Mac right now. /Mac will be removed before Docker for Mac leaves Beta, though, so please keep this in mind if you build automation around this feature. See the Docker for Mac Beta file system namespace documentation for more details.

Thanks for participating in the Docker for Mac Beta!

Best regards,


1 Like

Thank you so much David for pointing to the system namespace documentation for the Beta. This explains all I need to deal with this issue. I trust this will soon bubble up for relevant Google searches for others to find.