How to set redis DB ID in Docker container?

I have one data container and I would like to use several web_only containers (several forums on separate servers). How to I pass a DB ID to web_only container so that multiple forums use their own cache?

Without this the stats reported in Admin -> Reports are mixed up between different forums.

2 Likes

I’ve got the same issue. I have an existing redis cluster (with replication and failover) that I want Discourse to use, but I can’t find a way to tell Discourse which database index to use.

I’ve found the corresponding setting via this answer. It’s hidden in discourse_defaults.conf:

It’s called redis_db, so the corresponding setting in the container yaml should be DISCOURSE_REDIS_DB.

1 Like

Definitely do not do anything like this :fire: . Message Bus which is responsible for long polling relies on pub/sub, pub/sub is always on “db 0” not configurable.

If you try to co-host multiple Discourses on one Redis DB expect some very major amount of breakage.

5 Likes

Thank you for the warning! :bowing_man:

2 Likes

@sam is your warning :fire: from 2018 about the message bus exclusively linked to Redis db 0 still accurate, or can we use now a different redis instance database ID to host different discourse instances?

I noticed in the multisite-configuration-with-docker howto, there is a db_id: 2 defined, I thought that may refer to the redis database ID, thus this inquiry :face_with_monocle:

         secondsite:
           adapter: postgresql
           database: b_discourse
           pool: 25
           timeout: 5000
           db_id: 2
           host_names:
             - b.discourse.example.com

Yes this is still 100% correct afaik, PUB/SUB in redis is tied to DB 0. Discourse multisite is designed to work fine with multiple instances talking to 1 redis with db 0.

https://redis.io/topics/pubsub

Pub/Sub has no relation to the key space. It was made to not interfere with it on any level, including database numbers.

Publishing on db 10, will be heard by a subscriber on db 1.

2 Likes