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

1 Like

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 Likes

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

1 Like

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

9 Likes

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 Like

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 Like

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 Likes

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 Like

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 Likes

I tried getting discourse going inside lxd on ubuntu server on a raspberry pi 4 with a usb ssd, and it would just hang and timeout during rebuilds, the hanging was worse/earlier using a btrfs loopback storage pool and later using a zfs loopback storage pool. Memory was consistent around 1gb with 3gb peaks. The hangs would have ssh/top be responsibe but all usage activity would drop to negligible, indicating it had given up.

These days the lxd docs just recommend setting security.nesting to the string value true to enable docker usage, which is what I did. However the lxd docs also has a page for production configuration with about 20 settings that need changing, which I haven’t tried.

In the end I gave up on my lxd attempt for discourse, and just ran discourse via docker on the same machine.

Details of my efforts here:

Strangely the below lxd docker guide recommends btrfs despite the lxd docs recommending against it, and does not appear to use a partition for it (yet they set some extra settings, install other packages rather than docker.io, and attach the btrfs volume only to docker), so I wonder why I had such issues:

@vmsman can you share more details about your lxd setup, such as profiles, storage pools, and any system settings that needed changes, as seems you’ve had the most successful setup so far:

For lxd, some things I wonder about:

  • whether partitions for storage pools instead of loopback files would solve the performance issues enough the hanging issues goes away
  • whether using microcloud or an lxd cluster would help, or using ceph as the storage pool

All in all, despite not getting discourse working in lxd, I am very impressed with lxd and its easy of use. I previously spent months struggling with hashicorp, as hashicorp only seems interested in enterprise use cases. Whereas lxd just works and people seem supportive enough to enable small teams and indie devs to make progress.