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.

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.

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.

Thank you for the warning! :bowing_man:

@sam, актуально ли ваше предупреждение :fire: от 2018 года о том, что шина сообщений (message bus) привязана исключительно к Redis db 0, или теперь можно использовать другой ID базы данных Redis для размещения разных экземпляров Discourse?

Я заметил в руководстве multisite-configuration-with-docker, что там указано db_id: 2. Я подумал, что это может относиться к ID базы данных Redis, поэтому и возник этот вопрос :face_with_monocle:

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

Да, насколько мне известно, это всё ещё 100% верно: PUB/SUB в Redis привязан к базе данных 0. Мультисайтовая архитектура Discourse спроектирована так, чтобы корректно работать с несколькими экземплярами, подключёнными к одному Redis с базой данных 0.

Pub/Sub не имеет отношения к пространству ключей. Он создан так, чтобы не влиять на него ни на каком уровне, включая номера баз данных.

Публикация в базе данных 10 будет получена подписчиком в базе данных 1.