How to move from standalone container to separate web and data containers

well, what i want is to be able to host 3 discourse forums on my own VM.

From that i understand that i need to

  1. Separate the data and web containers (this also brings speedup when rebuilding the app)
  2. Configure 2 other discourse instances (somehow?) for my 2 other forums.

So this is why i don’t know exactly how to approach this situation.

1 Like

You may want to do that (mainly to reduce rebuild times), but this is not required, and doesn’t really have anything to do with running multiple sites.

To run three sites, you can either bootstrap them separately (which is rather easy, but triples resource requirements), or use these instructions for setting up multisite:

I’m running a setup like this (i.e. multisite, but without separating data and web containers or any other fanciness), and this works fine, but setup is indeed a bit tricky.

3 Likes

I’m trying to implement the separate containers, but with a remote database. I’ve followed these instructions above and the howto for setting up a remote postgres DB. The setup works, but I’m wondering why there are two identical references (under web_only and data) to the same database. It makes me believe I’m doing something wrong and the web_only container is not even using the data container.

Am I doing this correctly?

Here is my setup.

Under the web_only.yml I added:

  DISCOURSE_DB_SOCKET: ''
  DISCOURSE_DB_USERNAME: REMOVE
  DISCOURSE_DB_PASSWORD: REMOVE
  DISCOURSE_DB_HOST: xxx.ondigitalocean.com
  DISCOURSE_DB_NAME: REMOVE
  DISCOURSE_DB_PORT: 25060
  DISCOURSE_DB_BACKUP_PORT: 25060
  DISCOURSE_REDIS_HOST: data

under data.yml

I removed postgres.template.yml

templates:
#  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"

I also added the following:

env:
  # ensure locale exists in container, you may need to install it
  LANG: en_US.UTF-8
  DISCOURSE_DB_USERNAME: REMOVE
  DISCOURSE_DB_PASSWORD: REMOVE
  DISCOURSE_DB_HOST: REMOVE.ondigitalocean.com
  DISCOURSE_DB_NAME: REMOVE
  DISCOURSE_DB_PORT: 25060
  DISCOURSE_DB_BACKUP_PORT: 25060

If you’re using a remote database, you don’t need to create the data container which has a database in it. Note that you need both postgres and redis (so you might need the data container for that).

1 Like

but here i got only 1 container running without any error

I don’t know really what You understand by two containers but if You assume two containers mean two separate discourse instances then You’re looking in the wrong direction.

This article helps one set up a separate application and database container which is useful for advanced users looking for some flexibility.

If You want to install/host two discourse sites on the same machine, maybe look at discourse multisite:
Multisite configuration with Docker

1 Like

what I mean by container is you can see two running container when you type over host machine

docker ps

and sencond this 2container command i did not find where to set domain name

So which container was running? Assuming it was app then no, You’re running an old version of discourse-setup.

Do a git pull before proceeding to make sure you’re using the latest version of discourse-setup.

If You got data or web-only container running then You should check what caused the other one to not start. Usually, the web-only container fails to start because there is a process (web server) already running on port 80/443

yes app
oh no I git clone source code from github today.

I haven’t tried this personally but since @pfaffman is the genius who made this, maybe he can help with it.

Looking at the discourse-setup code on GitHub, I don’t see anything obvious that may cause it to not work.

What OS are you running your server on?

do server ubuntu
I have susscesfully run standlone container.
right now i am try this method Success - New Multisite Install on Dedicated server using ServerPilot, Nginx and Apache

Are you trying to achieve multisite or multi container?

benchmark as I said i run a stanlone forum for a month, when I want to a new one several ways have been dig

  1. I want to run separate standlone container on the same server ,no luck
  2. multisite docker different container for web and database as Multisite configuration with Docker, no luck
  3. your 2container no luck
  4. Success - New Multisite Install on Dedicated server using ServerPilot, Nginx and Apache this one is trying ,maybe it works

If You just want to run a 2nd standalone container, You will have to modify the yml files to use different directory and port. Possibly also disable the letsencrypt

after all these get fixed ,I want to write some turtorial for beginners

Just FYI, if You want to benchmark performance, You shouldn’t do that on a production machine. Rather spin up a separate VPS and use that for benchmarking.

Trying to run two separate instances of discourse on the same machine may lead you into a very broken install and that isn’t ideal.

That command will create separate data and web containers if and only if there is no app.yml when it is run. It will not create two web containers.

1 Like

before I run this command it seems there is app.yml already .

I think this is very crucial, shall be added to the OP and possibly on GitHub as well?

I think I should have left this feature undocumented. And, actually, it’s no help to move to a two container config, so it probably doesn’t belong here at all.

1 Like