Reputation: 11
I am trying to connect docker compose with my local mongodb , everything works fine and connection is working but my db is empty inside the container , i cant see my old data , however my local database is full . i am using windows for now for testing , this is how my docker looks like
version: "3"
services:
api:
container_name : docker-node-mongo
build: .
ports:
- "3500:3001"
- "5858:5858"
links:
- mongo
mongo:
container_name : mongo
image: mongo
volumes:
- c:/data/db:/data/db
ports:
- '27017:27017'
i understand that the trick is with volumes: for my mongo . - data:/data/db , ./data/db:/data/db , $HOME/data/db , nothing works.
please help
Upvotes: 1
Views: 3235
Reputation: 1357
Further review of the Dockerfile
for mongo here shows that it is exposing two volumes. You are only mapping one of those. You might consider changing your docker-compose.yml
file to include the configdb
volume.
version: "3"
services:
api:
container_name : docker-node-mongo
build: .
ports:
- "3500:3001"
- "5858:5858"
links:
- mongo
mongo:
container_name : mongo
image: mongo
volumes:
- c:/data/db:/data/db
- c:/data/configdb:/data/configdb
ports:
- '27017:27017'
Upvotes: 2
Reputation: 1357
Assuming you are running "Docker Destop" on Windows. Your volume
settings in your docker-compose
file looks correct. However, on Windows you need to configure some additional settings to make a Windows drive visible to Docker containers.
Note: If you subsequently change your login or password, you will need to use the "Reset credentials" link at the bottom of the "Shared Drives" settings page.
Upvotes: 0