Reputation: 15684
this is my docker-compose file
version: '3'
services:
mongo:
image: mongo:latest
ports:
- 27017:27017
volumes:
- dbdata:/data/db
volumes:
dbdata:
When I start and stop the mongo container I lose all data. What am I missing out on ?
Upvotes: 1
Views: 111
Reputation: 15684
Don't know why it wasn't working but it is now solved
After running my docker-compose file I see the mydata
volume when I run docker volume ls
.
That volume persists through container destruction.
Upvotes: 0
Reputation: 3621
Try running docker volume create dbdata
in order to create a persistent volume, redeploy your stack and it should work after that. I.e. the first reboot will cause a data wipe, but after that it should persist.
I hope this helps you
Upvotes: 1