# Discourse bootstrap和rebuild区别

**URL:** <https://www.isharkfly.com/t/discourse-bootstrap-rebuild/17161>\
**Category:** Discourse\
**Tags:** discourse\
**Created:** [April 11, 2025, 8:04am UTC](https://www.isharkfly.com/t/discourse-bootstrap-rebuild/17161 "2025-04-11T08:04:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitewatercn](https://www.isharkfly.com/user_avatar/www.isharkfly.com/whitewatercn/32/2131_2.png) [@whitewatercn](https://www.isharkfly.com/u/whitewatercn)\
**Post date:** [April 11, 2025, 8:04am UTC](https://www.isharkfly.com/t/discourse-bootstrap-rebuild/17161/1 "2025-04-11T08:04:41Z")

</div>

虽然discourse meta已经有人说过了，但我还是没看明白

rebuild = destroy + bootstrap + build

那直接Bootstrap，之前的app去哪了？

> **[What's the different between rebuild and bootstrap](https://meta.discourse.org/t/whats-the-different-between-rebuild-and-bootstrap/60315)**
>
> what’s the different between ./launcher rebuild app ./launcher bootstrap app they both tool slow , is where any command to modify config like UNICORN\_WORKERS and then fast test it

---

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [April 11, 2025, 12:46pm UTC](https://www.isharkfly.com/t/discourse-bootstrap-rebuild/17161/2 "2025-04-11T12:46:13Z")

</div>

上面的说法是，基本上是一样的。

 ![2025-04-11_08-37-39](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/6/e/6e1f9061ec8e768422b8dbd9b34420754c784617.jpeg)

我的理解是：

**Bootstrap**  
这个就是从 Docker 的容器配置文件中重构一个 Docker 镜像，然后把这个镜像挂在到容器上。但 Docker 上老的容器没有被销毁，还在运行，并且还是用的老的镜像。

**rebuild**  
这个其中有一步还是 Bootstrap 构建这个镜像，并且把这个镜像挂到容器上。

然后销毁老的镜像，重启这个挂在的新镜像。

Rebuild 的执行顺序是：stop, bootstrap, destroy and then start。

## 区别

根据上面的说法，我的理解就是 Discourse 最耗时地方其实就是镜像的构建，因为 Discourse 针对每个安装实例都在本地构建镜像。

有时候在构建镜像的时候可能会失败。

镜像构建好后，肯定是要挂到容器上运行的，所以最后几步还是要挂载。

另外，Rebuild 的执行顺序是：stop, bootstrap, destroy and then start。

因此，针对 Discourse Bootstrap 只是构建的一个过程，其中少了 Stop，Destroy 和 Start 这几个步骤。

所以启动的应该还是老的容器，新构建的容器还没挂上去。

可以用 **Bootstrap** 来验证能不能正常构建镜像，以避免镜像构建错误服务又启不来了。

对大部分情况，我们应该用的都是 **rebuild** 。
