# Update Graylog Docker Stack from 5.2 to 6.0.1, incl. change from Elasticsearch to Opensearch and upgrade mongodb

**URL:** https://community.graylog.org/t/update-graylog-docker-stack-from-5-2-to-6-0-1-incl-change-from-elasticsearch-to-opensearch-and-upgrade-mongodb/32411
**Category:** Documentation Campfire
**Tags:** docker, mongodb
**Created:** [May 14, 2024, 9:35pm UTC](https://community.graylog.org/t/update-graylog-docker-stack-from-5-2-to-6-0-1-incl-change-from-elasticsearch-to-opensearch-and-upgrade-mongodb/32411 "2024-05-14T21:35:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![schneich](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/schneich/32/13807_2.png) [@schneich](https://community.graylog.org/u/schneich)
#### Post date: [May 14, 2024, 9:35pm UTC](https://community.graylog.org/t/update-graylog-docker-stack-from-5-2-to-6-0-1-incl-change-from-elasticsearch-to-opensearch-and-upgrade-mongodb/32411/1 "2024-05-14T21:35:51Z")

</div>

Dear community,

during the last couple of days, I was trying to upgrade my Docker Graylog Stack. I ran into several issues and finally managed to solve them all.  
I thought it worth while to document, so that others can benefit from my learning curve. 🙂

**Background**

- This was my initial post: [Change from Elasticsearch to opensearch: Node ID problem](https://community.graylog.org/t/change-from-elasticsearch-to-opensearch-node-id-problem/32370)
- Then I got it running successfully - as a new, empty environment: [How to run Graylog 6, MongoDB and Opensearch in a Docker Stack](https://community.graylog.org/t/how-to-run-graylog-6-mongodb-and-opensearch-in-a-docker-stack/32377)
- My Docker environment runs on a Ubuntu server.
- I am using Portainer to manage my containers.
- Graylog is started as a Docker Stack (-\> [compose.yaml](https://community.graylog.org/t/how-to-run-graylog-6-mongodb-and-opensearch-in-a-docker-stack/32377), from within Portainer)
- My Graylog 5.2 was based on Elasticsearch. I wanted to switch to Opensearch.

**steps taken to upgrade**

- stop the old Graylog 5.2, Elasticsearch and mongodb container
- go to the CLI of the server:  
`sudo su`
- create backup of the persistant folders (./Docker/Graylog/):  
`cp -a /home/uadmin/Docker/Graylog/ /home/uadmin/Docker/Graylog_Backup/`
- remove the old containers and delete the unused images
- create the opensearch folders:  
`mkdir /home/uadmin/Docker/Graylog/opensearch-data`  
`mkdir /home/uadmin/Docker/Graylog/opensearch-data/nodes`
- simply copy the content of the nodes-folder from Elasticsearch into the new folder from Opensearch:  
`cp -a /home/uadmin/Docker/Graylog/es_data/nodes/* /home/uadmin/Docker/Graylog/opensearch-data/nodes/`
- Opensearch needs user 1000 to be able to access these folders:  
`chown -R 1000:1000 /home/uadmin/Docker/Graylog/opensearch-data/`  
`chmod -R 770 /home/uadmin/Docker/Graylog/opensearch-data/`
- delete all old graylog data, except the config-folder:  
`find /home/uadmin/Docker/Graylog/graylog_data/ -mindepth 1 -maxdepth 1 ! -name "config" -exec rm -rf {} \;`
- check again, if the access rights are as needed: Graylog needs user 1100, Opensearch needs user 1000.
- start Graylog Docker Stack with the new [compose.yaml](https://community.graylog.org/t/how-to-run-graylog-6-mongodb-and-opensearch-in-a-docker-stack/32377). → check logs
- I stopped Graylog and Opensearch, before I upgraded the mongodb to the new version:  
`docker exec mongodb mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )'`
- start Opensearch and let it work through the indices → check logs
- start Graylog → check logs

My new version of Graylog in the version 6.0.1 seems to be running stable for an our now. 😉

I am far away from being a pro, so any feedback is very much welcome.

- Did I do it correctly? Anything to improve for next time?
- especially: is setting the compatibilityVersion to 6.0 for the mongodb enough or do I need to do some more steps?
