I have 3-node docker swarm mode cluster (1 manager and 2 workers).
Now I want to deploy a mongodb service to the cluster and I would like to store the database on a persistent storage that I've mounted under /mnt/data
. So basically I want the service to use my mounted storage inside each containers /db/data
.
How do I achieve this?
I made myself familiar with docker service create --mount
but
volume
or a bind-mount
?volume
how can I tell docker to store this volume on /mnt/data
To couple the mongodb services to a specific node (where the storage is mounted) I added a label
to the corresponding node and start the docker service with a constraint.
you need to bind mount the volume with mongodb data. follow the below steps on master server
you can also look at setting up mongodb cluster in swarm to have the db running in HA mode. follow the below link https://medium.com/@kalahari/running-a-mongodb-replica-set-on-docker-1-12-swarm-mode-step-by-step-a5f3ba07d06e
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With