# How to set redis DB ID in Docker container?

**URL:** https://meta.discourse.org/t/how-to-set-redis-db-id-in-docker-container/56267
**Category:** Self-hosting
**Created:** [2017年一月24日 12:30 UTC](https://meta.discourse.org/t/how-to-set-redis-db-id-in-docker-container/56267 "2017-01-24T12:30:23Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![ryanerwin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryanerwin/32/94589_2.png) [@ryanerwin](https://meta.discourse.org/u/ryanerwin)
#### Post date: [2020年六月5日 13:49 UTC](https://meta.discourse.org/t/how-to-set-redis-db-id-in-docker-container/56267/6 "2020-06-05T13:49:49Z")

</div>

@sam，你 2018 年关于消息总线仅链接到 Redis `db 0` 的警告：fire: 是否仍然准确？或者我们现在能否使用不同的 Redis 实例数据库 ID 来托管不同的 Discourse 实例？

我注意到在 [multisite-configuration-with-docker](https://meta.discourse.org/t/multisite-configuration-with-docker/14084) 的教程中，定义了 `db_id: 2`。我原以为这可能指的是 Redis 数据库 ID，因此提出此疑问：face\_with\_monocle:

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

```

[quote=“TomekB, post:1, topic:56267”]  
如果没有这个设置，管理员面板中“报告”部分统计的数据会在不同论坛之间混淆。[/quote]

[quote=“rluba, post:3, topic:56267”]  
该设置名为 `redis_db`，因此容器 YAML 中的对应设置应为 `DISCOURSE_REDIS_DB`。[/quote]

[quote=“sam, post:4, topic:56267, full:true”]  
绝对不要这样做：fire:。负责长轮询的消息总线依赖于发布/订阅（pub/sub）功能，而 pub/sub 始终在“db 0”上运行，无法配置。

如果你尝试在同一个 Redis 数据库中托管多个 Discourse 实例，预计会出现非常严重的故障。[/quote]

---

_[View the full topic](https://meta.discourse.org/t/how-to-set-redis-db-id-in-docker-container/56267)._
