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

This is an answer supplied by 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, 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:

$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:

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


Useful Links


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?

1 Like