# Followed github guide, vps. help me apply ram/vcpu limits

**URL:** https://meta.discourse.org/t/followed-github-guide-vps-help-me-apply-ram-vcpu-limits/382578
**Category:** Self-hosting
**Tags:** server-resources
**Created:** [September 14, 2025, 10:16am UTC](https://meta.discourse.org/t/followed-github-guide-vps-help-me-apply-ram-vcpu-limits/382578 "2025-09-14T10:16:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![maxjohnson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maxjohnson/32/521500_2.png) [@maxjohnson](https://meta.discourse.org/u/maxjohnson)
#### Post date: [September 14, 2025, 10:16am UTC](https://meta.discourse.org/t/followed-github-guide-vps-help-me-apply-ram-vcpu-limits/382578/1 "2025-09-14T10:16:35Z")

</div>

(1)

this is ubuntu 24 VPS. discourse already using 10gigs of ram. that’s not okay.

It seems like it build a docker run command. While this included

–shm-size=512m

I would prefer apply additional cpu and ram constraints as I don’t want it to suck up 4c12r since other dockers will live here. Can I simply copy the resultant command or is it stored somewhere. I plan to docker stop docker rm to inject

–cpu-shares=1100 --shm-size=512m --memory=4g --memory-swap=8g --kernel-memory=5500m

is there a better way to apply these constraints?

(2)

is “app” really the name of the container? –name app

docker ps shows that app is the only one of the one containers running

(3)

this isn’t munged. the review screen before starting showed my provider smtp domain

DISCOURSE\_SMTP\_DOMAIN=[discourse.example.com](http://discourse.example.com)

why is it literally this now? how do I fix it. fun fact it was able to email me a confirmation link

(4)

the docker run slightly munged

/usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en\_US.UTF-8 -e RAILS\_ENV=production -e UNICORN\_WORKERS=8 -e UNICORN\_SIDEKIQS=1 -e RUBY\_GC\_HEAP\_GROWTH\_MAX\_SLOTS=40000 -e RUBY\_GC\_HEAP\_INIT\_SLOTS=400000 -e RUBY\_GC\_HEAP\_OLDOBJECT\_LIMIT\_FACTOR=1.5 -e DISCOURSE\_DB\_SOCKET=/var/run/postgresql -e DISCOURSE\_DB\_HOST= -e DISCOURSE\_DB\_PORT= -e DISCOURSE\_FORCE\_HTTPS=true -e LC\_ALL=en\_US.UTF-8 -e LANGUAGE=en\_US.UTF-8 -e DISCOURSE\_HOSTNAME=a.shop -e DISCOURSE\_DEVELOPER\_EMAILS=x -e DISCOURSE\_SMTP\_ADDRESS=x -e DISCOURSE\_SMTP\_PORT=587 -e DISCOURSE\_SMTP\_USER\_NAME=x -e DISCOURSE\_SMTP\_PASSWORD=Fx -e DISCOURSE\_SMTP\_DOMAIN=[discourse.example.com](http://discourse.example.com) -e DISCOURSE\_NOTIFICATION\_EMAIL=x -e LETSENCRYPT\_ACCOUNT\_EMAIL=x -h hoho-app -e DOCKER\_HOST\_IP=172.17.0.1 --name app -t -p 80:80 -p 443:443 -v /var/discourse/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address xx local\_discourse/app /sbin/boot

I followed these instructions

> <https://github.com/discourse/discourse/blob/main/docs/INSTALL-cloud.md>

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [September 21, 2025, 7:34am UTC](https://meta.discourse.org/t/followed-github-guide-vps-help-me-apply-ram-vcpu-limits/382578/2 "2025-09-21T07:34:48Z")

</div>

This is an answer supplied by [ask.discourse.org](http://ask.discourse.org). Please report on its usefulness.

* * *

### 1. Setting Persistent CPU & RAM Limits for Discourse Docker

When installing Discourse on a VPS via the [official GitHub guide](https://github.com/discourse/discourse/blob/main/docs/INSTALL-cloud.md), resource limits like `--memory` and `--cpus` are **not** included by default. While you can manually add such flags to the Docker run command, any changes done directly with `docker stop` and a new `docker run` will be lost after running `./launcher rebuild app`. The launcher script always recreates the container.

**Recommended approaches:**

**a) Launcher Script Modification**  
To persistently enforce resource limits, you must modify the `launcher` script that Discourse uses to start Docker containers. For example, around line 289, adapt:

```bash
$docker_path run $restart_policy "${env[@]}" -h "`hostname`-$config" \
    -m="4g" --cpus="2.0" -e DOCKER_HOST_IP=$docker_ip ...

```

This ensures every `./launcher rebuild` creates the container with your limits.

Source and further info:

- [Limiting Discourse memory usage on a dedicated box](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378)
- [Switches for resource constrained VPS?](https://meta.discourse.org/t/switches-for-resource-constrained-vps/383216/)

**b) Editing the Docker Command Directly**  
While it’s technically possible to run Docker with custom limits by copying your rebuilt `docker run` command, this is not persistent and is **not recommended**.

There’s not yet an official, persistent “built-in” method to pass Docker `--memory` or `--cpus` args for Discourse’s standard deployment tooling, short of modifying the launcher.

* * *

### 2. Container Name

By default, Discourse’s launcher names the container `app`. You can confirm this with `docker ps`. Changing the container name would also require modifying the launcher or templates directly.  
Read more: [Discourse in a Docker container](https://meta.discourse.org/t/discourse-in-a-docker-container/10844)

* * *

### Useful Links

- [Limiting Discourse memory usage on a dedicated box](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378)
- [Configure Discourse Docker on servers with more RAM and CPU](https://meta.discourse.org/t/configure-discourse-docker-on-servers-with-more-ram-and-cpu/18569)

* * *

If you’re looking for a more elegant and persistent way (like a template or supported launcher feature), check this related discussion:  
[Switches for resource constrained VPS?](https://meta.discourse.org/t/switches-for-resource-constrained-vps/383216/)

---

<div class="post-metadata">

### Author: ![nineb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nineb/32/522106_2.png) [@nineb](https://meta.discourse.org/u/nineb)
#### Post date: [September 29, 2025, 9:19am UTC](https://meta.discourse.org/t/followed-github-guide-vps-help-me-apply-ram-vcpu-limits/382578/3 "2025-09-29T09:19:15Z")

</div>

neat. After I confirm snapshots can be restored like I expect I will give this hack a try

Are unicorns directly 2x related to the number of VPS vCPUs?
