0

Using Windows 10 Pro.

This is one of the services under my docker_compose.yml file.

version: '3'
networks:
    demo-net:
services:
    mongodb:
        image: mongo:latest
        container_name: mongodb
        restart: always
        environment:
            MONGO_INITDB_ROOT_USERNAME: root
            MONGO_INITDB_ROOT_PASSWORD: root
            MONGO_INITDB_DATABASE: admin
        ports:
            - 27017:27017
        volumes:
            - ./mongo_data:/data/db
        networks:
            - demo-net

When I am doing docker_compose up in vs code, I am getting this error

mongodb    | 2020-05-07T16:53:34.336+0000 W  STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
mongodb    | 2020-05-07T16:53:34.337+0000 F  STORAGE  [initandlisten] Reason: 1: Operation not permitted
mongodb    | 2020-05-07T16:53:34.337+0000 F  -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 915
mongodb    | 2020-05-07T16:53:34.337+0000 F  -        [initandlisten]
mongodb    |
mongodb    | ***aborting after fassert() failure
mongodb    |
mongodb    |
mongodb exited with code 14

Could anyone tell me what I am doing wrong? This same piece of code is working on a friend's mac. Will keeping MongoDb in my local as well as using it in the container will cause any problem?

Pratik
  • 5
  • 1
  • 4
  • the issue is about the volume: [this answer maybe can help you](https://stackoverflow.com/a/73565165/18574128) – huhx Sep 01 '22 at 06:45

1 Answers1

0

EDIT:

Your issue is container / host permissions. This answer might help.

ORIGINAL ANSWER:

Will keeping MongoDb in my local as well as using it in the container will cause any problem?

Yes, if you are running on the same default port (27017). You can avoid this by mapping a different local port, e.g. if your docker compose:

    ports:
        - 27018:27017

Then connect to mongo on port 27018 for the container.

Belly Buster
  • 8,224
  • 2
  • 7
  • 20
  • Thanks for your reply, but my main question is I am not able to run the MongoDB docker, I have not installed mongo DB on my local when I am running this docker-compose file, I am getting the above-mentioned error, `***aborting after fassert() failure`. `\mongo_data` - this I have created the folder in my local to store the data. Could you please tell me why I am getting this error ? – Pratik May 09 '20 at 11:46
  • Very likely a permissions error. Try it without the volume mount and see if that works. – Belly Buster May 09 '20 at 12:23
  • Without volume mount its working, this was the same case with **PostgreSQL**, and here in **MongoDB** also. Is there any way that I can run a **MongoDB** container by keeping data in my local/volume mount? – Pratik May 10 '20 at 06:03
  • No, you will need a volume mount to retain the data between restarts. Answer edited to reflect permissions issue. – Belly Buster May 10 '20 at 08:37