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:
Create mongo dump
docker exec -i db /usr/bin/mongodump --username <username> --password <password> --authenticationDatabase admin --db <database_name> --out dump
Run new mongo container
docker run -d --name dbnew -i mongo:4.4 --smallfiles --replSet rs0 --oplogSize 128
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>
Check new db works fine and remove old container
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:
comment from stefan.badenhorst