Home > Mobile >  how update mongo4.0.28 in docker container
how update mongo4.0.28 in docker container

Time:08-06

i use docker run --name db -d mongo:4.0 --smallfiles --replSet rs0 --oplogSize 128

docker exec -ti db mongo --eval "printjson(rs.initiate())"

Then start Rocket.Chat linked to this mongo instance:

docker run --name rocketchat -p 80:3000 --link db --env ROOT_URL=http://localhost --env MONGO_OPLOG_URL=mongodb://db:27017/local -d rocket.chat now mongo 4.0 is depricated. how can i upgrade mongo in docker?

CodePudding user response:

You can do it this way:

  1. Create mongo dump

    docker exec -i db /usr/bin/mongodump --username <username> --password <password> --authenticationDatabase admin --db <database_name> --out dump

  2. Run new mongo container

    docker run -d --name dbnew -i mongo:4.4 --smallfiles --replSet rs0 --oplogSize 128

  3. Restore dump to new container

    docker cp dbnew:/dump dump docker exec -i dbnew /usr/bin/mongorestore --username <username> --password <password> --authenticationDatabase admin --db <database_name> /dump/<database_name>

  4. Check new db works fine and remove old container

  5. Rename new container

    docker rename dbnew db


If you want your new container to be persistent (which I think you would) you need to use docker volumes.

CodePudding user response:

https://forums.rocket.chat/t/mongodb-version-4-0-21-is-deprecated-please-upgrade-your-installation/12320/4

comment from stefan.badenhorst

  • Related