Parse-Server Docker-Container custom volume saved data not working

Viewed 29

I am new to parse-server and to docker world, and I think that either I did not understand this properly or it is not working. Sorry if this will come as a stupid question.

So from docker documentation, I understand that if I want to bind a folder location to my docker location I have to do something like this.

volumes:
  - /host/path/to/folder:/docker/path/to/folder

But the thing that I am missing is that after I create all my docker and I bind the volume paths like this when I am adding new rows into my MongoDB database I will have nothing saved into those folders. Can anyone explain to me what I am doing wrong?

Basically, I am trying to save all my changes from MongoDB and the server into a local folder.

My docker-compose:

version: '3.9'

services:
  database:
    image: mongo:6.0.1
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: admin
    volumes:
      - ./data/mongodb:/data/mongodb

  server:
    restart: always
    image: parseplatform/parse-server:5.2.5
    ports:
      - 1337:1337
    environment:
      - PARSE_SERVER_APPLICATION_ID=COOK_APP
      - PARSE_SERVER_MASTER_KEY=MASTER_KEY_1
      - PARSE_SERVER_DATABASE_URI=mongodb://admin:admin@mongo/parse_server?authSource=admin
      - PARSE_ENABLE_CLOUD_CODE=yes
      - PARSE_SERVER_URL=http://10.0.2.2:1337/parse
    links:
      - database:mongo
    volumes:
      - ./data/server:/data/server

  dashboard:
    image: parseplatform/parse-dashboard:4.1.4
    ports:
      - "4040:4040"
    depends_on:
      - server
    environment:
      - PARSE_DASHBOARD_APP_ID=COOK_APP
      - PARSE_DASHBOARD_APP_NAME=COOK_APP
      - PARSE_DASHBOARD_MASTER_KEY=MASTER_KEY_1
      - PARSE_DASHBOARD_USER_ID=admin
      - PARSE_DASHBOARD_USER_PASSWORD=admin
      - PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=true
      - PARSE_DASHBOARD_SERVER_URL=http://localhost:1337/parse
    volumes:
      - ./data/dashboard:/data/dashboard

UPDATE:

After I've checked your response regarding ./data/mongodb:/data/db is working just partially. In a sense that I have these 2 cases.

  1. If I will use it like this data/mongodb:/data/db without that . in order to save that data into my root directory, then everything is working fine. But I would like to save it in my local directory where all the projects will be.

  2. So if I am doing as you said ./data/mongodb:/data/db in order to save it into the local directory my MongoDB is not going to star and I will get this error message for some unknown reason.

{"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"W", "c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."} 2022-09-07T16:05:52.524152876Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"STORAGE", "id":28595, "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"1: Operation not permitted"}} 2022-09-07T16:05:52.524168870Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"ASSERT", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":702}} 2022-09-07T16:05:52.524183328Z {"t":{"$date":"2022-09-07T16:05:52.523+00:00"},"s":"F", "c":"ASSERT", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

Any idea why?

1 Answers

If you check the "where to store data" section of the mongo image documentation (https://hub.docker.com/_/mongo), you will see that, inside the container, mongo actually saves the data in the folder /data/db (and not /data/mongodb). So you will have to bind it:

    volumes:
      - ./data/mongodb:/data/db
Related