Docker Community Forums

Share and learn in the Docker community.

Mongodb + compose with volumes, data not persisted

beta

(Ramon Bosch Smit) #1

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

My compose file contains this:

api:
build: ./service
restart: always
ports:
- "4000:4000"
links:
- db:apidb
db:
image: mongo:latest
restart: always
volumes:
- /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.


(David Sheets) #2

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,

David


(Ramon Bosch Smit) #3

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.