How to start discourse inside a linux container?

Hello Discourse Friends!
I managed to setup discourse inside a LXD/LXC and want to ask, is there a recommendation how to start the deamon process?

Is there a better ‘method’ than starting it with:

bundle exec rails s -b 0.0.0.0 2>&1 > /var/log/discourse.log

How can this be done with systemd? Thank you in advance.

Kind Regards,
Ingo Baab from Germany

2 个赞

If you want to install Discourse in anything resembling a production environment, you should follow the cloud install instructions. https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md

2 个赞

Thank you for this answer, Jay, but I am happy with my installation. Works fine inside Linuxcontainer… (I do not like docker at all…)

2 个赞

There are a zillion ways that you might install Discourse that can all work just fine, but only one is supported here.

9 个赞

Hi,
how to install it using LCX container. I dont want to use docker, because I use proxmox to manage VMs and docker cant be installed in LCX container.

1 个赞

You would be entering uncharted territory and would need to build something that you alone support. The code for discourse docker is open so you could adapt it, I guess.

1 个赞

You mean an LXC container? I know someone who worked for canonical and had a lot to do with LXC. He uses docker now.

I just installed Discourse in a Docker container inside an LXD container, which may seem weird but it’s something LXD was intentionally designed to support.

How to Install Discourse in an LXD / Docker Container

If you encounter problems with Docker / Discourse failing to run in LXD then you’ll likely need to tweak some settings in your host’s /etc/sysctl.conf namely:

kernel.keys.maxkeys=2000
kernel.keys.maxbytes=200000
net.ipv4.tcp_mem=182757 243679 365514
net.core.netdev_max_backlog=182757

These are production values for LXD and for me they were neccessary to get Discourse running.

3 个赞

Can you send this guide somewhere else? The site is blocking access for me, and I would also like to install discourse on LXC ProxMox

1 个赞

That’s wrong

Just follow the next post from the link above :slight_smile:

edit: I installed Discourse the official way inside a LXC container this way :wink:

4 个赞

我在树莓派 4 的 Ubuntu 服务器上尝试通过 LXD 运行 Discourse,并使用 USB SSD。在重建过程中,它会挂起并超时。使用 btrfs 回环存储池时挂起更严重/更早,使用 zfs 回环存储池时挂起稍晚。内存占用稳定在 1GB 左右,峰值达到 3GB。挂起时 SSH/top 仍然响应,但所有使用活动都会下降到可忽略的水平,表明它已放弃。

如今,LXD 文档仅建议将 security.nesting 设置为字符串值 true 来启用 Docker 使用,我就是这样做的。然而,LXD 文档还有一个关于生产环境配置的页面,其中包含大约 20 个需要更改的设置,我还没有尝试过。

最后,我放弃了在 LXD 中运行 Discourse 的尝试,而是在同一台机器上通过 Docker 运行 Discourse。

我的努力细节如下:

奇怪的是,下面的 LXD Docker 指南推荐使用 btrfs,尽管LXD 文档不推荐它,并且似乎没有为它使用分区(但他们设置了一些额外的设置,安装了 docker.io 以外的其他软件包,并将 btrfs 卷仅附加到 Docker),所以我很想知道为什么我遇到了这些问题:

@vmsman 你能分享更多关于你的 LXD 设置的细节吗?例如配置文件、存储池以及需要更改的任何系统设置,因为你似乎拥有迄今为止最成功的设置:

对于 LXD,我有一些疑问:

  • 使用存储池分区而不是回环文件是否足以解决性能问题,从而消除挂起问题?
  • 使用 MicroCloud 或 LXD 集群是否有帮助,或者使用 Ceph 作为存储池是否有帮助?

总而言之,尽管没有在 LXD 中成功运行 Discourse,但我对 LXD 及其易用性印象深刻。我之前花了几个月的时间在 HashiCorp 上挣扎,因为 HashiCorp 似乎只对企业用例感兴趣。而 LXD 则能正常工作,而且人们似乎足够支持,能够让小型团队和独立开发者取得进展。