I want to use Dockerizing MongoDB and store data in local volume.
But .. failed ...
It has mongo:latest
images
kerydeMacBook-Pro
For anyone running MongoDB container on Windows: as described here, there's an issue when you mount volume from Windows host to MongoDB container using path (we call this local volume
).
You can overcome the issue using a Docker volume
(volume managed by Docker):
docker volume create mongodata
Or using docker-compose
as my preference:
version: "3.4"
services:
....
db:
image: mongo
volumes:
- mongodata:/data/db
restart: unless-stopped
volumes:
mongodata:
Tested on Windows 10 and it works