Unable to start docker mongo image on windows

前端 未结 4 1226
攒了一身酷
攒了一身酷 2020-12-18 18:21

When starting the image I get the following error:

 2019-02-27T17:09:41.095+0000 E STORAGE  [initandlisten] WiredTiger error (17) [1551287381:95206][1:0x7fae         


        
相关标签:
4条回答
  • 2020-12-18 18:48

    If you are using docker-compose then following is the way replicate the answer above.

    services:
      mongodb_container:
        ...
        volumes:
          - mongodata:/data/db
    volumes:
      mongodata:
    

    Please not that the sample above indicates only needed parts of the yml file for the mongodb storage.

    0 讨论(0)
  • 2020-12-18 18:50

    Although Augustas is right, but I found this answer particularly useful with docker-compose.yml.

    What you can do as a workaround is:

    1. Create a .env file in the same path as your docker-compose file and store the current path in an environment variable like this:
    MONGO_HOST_DATA=/Users/user123/MyMongoProject //path to mongo data folder (for C:\Users\user123\MyMongoProject)
    
    1. Now, in your docker-compose file, replace the above-mentioned variable:
        services:
          my-mongo-db:
          build: ./database
          ports:
           - 32815:27017
          volumes:
        - ${MONGO_HOST_DATA}/database/db:/data/db
    
    • If you want to see how the actual path replaced the environment variable, you can use the following command:
    docker-compose config
    

    Additionally, if you use any disk drive other than C:\ you might want to change the Docker file sharing settings:

    Hope this helps.

    0 讨论(0)
  • 2020-12-18 18:53

    WARNING (Windows & OS X): The default Docker setup on Windows and OS X uses a VirtualBox VM to host the Docker daemon. Unfortunately, the mechanism VirtualBox uses to share folders between the host system and the Docker container is not compatible with the memory mapped files used by MongoDB (see vbox bug, docs.mongodb.org and related jira.mongodb.org bug). This means that it is not possible to run a MongoDB container with the data directory mapped to the host.

    Answer from docker mongo GitHub

    Workaround to persist data:

    docker volume create --name=mongodata
    docker run -d -p 27017:27017 -v mongodata:/data/db --name=mymongo mongodb:3.3
    

    More info here

    0 讨论(0)
  • 2020-12-18 18:56

    Not entirely the same issue, but I saw the same error messages when simply spinning up a Docker container for mongo in Ubuntu and attempting to mount an existing directory to the container:

    docker run --name some-mongo -p 27017:27017 -v $PWD/db-data:/data/db -d mongo
    

    In my case the errors only showed up if I was trying to run the command from a directory on my mounted HDD, and I was able to solve it by migrating my codebase with the /db-data directory to my SSD where Ubuntu is installed.

    0 讨论(0)
提交回复
热议问题