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

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

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.

「いいね!」 6

Thank you for the warning! :bowing_man:

「いいね!」 2

@sam さん、2018 年に出された「メッセージバスが Redis の db 0 のみにリンクされている」という警告 :fire: は現在も正確ですか?それとも、異なる Discourse インスタンスをホストするために、別の Redis インスタンスのデータベース ID を使用できるようになりましたか?

multisite-configuration-with-docker のハウツーで db_id: 2 が定義されているのを見て、これは Redis のデータベース ID を指しているのかと思い、この質問をしました :face_with_monocle:

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

はい、私の知る限り、これは 100% 正しいです。Redis の PUB/SUB は DB 0 に紐付いています。Discourse のマルチサイト機能は、1 つの Redis(db 0)に対して複数のインスタンスが接続しても正常に動作するように設計されています。

Pub/Sub はキー空間とは無関係です。データベース番号を含む、いかなるレベルでもキー空間に干渉しないように設計されています。

db 10 でパブリッシュしても、db 1 のサブスクライバーには受信されます。

「いいね!」 2