This is an advanced setup. Don’t follow this unless you are experienced with Linux server administration and Docker.
Added by @pfaffman 2019-12-11.
NOTE: If you want to create a 2 container site you can do this:
It works just like normal except it’ll create separate
web_only containers and generate a random password for the database. If you already have an
app.yml you’ll need to rename it, or
discourse-setup will just update it. You could then copy a backup into
/var/discourse/shared/web_only/backups/default and restore that, which is a little easier for novice system administrators than what’s described below.
I managed to migrate to two containers. If anyone else needs instructions, this is how it worked for me.
The process includes backup, setting up separate web and data containers and restore data.
Stop current standalone container
./launcher stop app
containers/rename them to whatever you’d like, e.g.
if you rename them, please pay attention to the entries
If you renamed
web_rocks.ymlyou need to modify the entry in
volumes: - volume: host: /var/discourse/shared/web_rocks guest: /shared - volume: host: /var/discourse/shared/web_rocks/log/var-log guest: /var/log
Accordingly, do the similar editing in
data.yml and set a password for the database. Then:
- come to the container’s root folder
./launcher bootstrap data2(data2 or whatever new name you gave it)
./launcher start data2(using new name again)
- if everything goes smoothly you can connect to the container via:
./launcher enter data2(again using the new name)
- Exit the container by
Firstly, change the template and expose ports as your
Secondly, make sure you are linking to the right data container. If you renamed the data.yml to ‘something_else’ put it in for ‘name’.
# Use 'links' key to link containers together, aka use Docker --link flag. links: - link: name: data alias: data
Although we don’t want to expose ssh or any other ports anymore, you’d still need to expose 80 and 443 port for web access. This depends on whether you have a nginx running in the front and how you connect container with it.
Somewhere in there you’ll find this block:
DISCOURSE_DB_USERNAME: discourse DISCOURSE_DB_PASSWORD: mypassword DISCOURSE_DB_HOST: data DISCOURSE_REDIS_HOST: data
- Enter the password you set inside the data container.
- Enter the data container’s alias you just wrote down. For
REDIS_HOST. It has to match the links block we mentioned.
- You probably didn’t change the
You’ll find the values for
DISCOURSE_HOSTNAME and many more. You already have these values in your
app.yml. Copy them from there.
In the hooks section remember to set any additional plugins you already use inside app.yml
Now you should be ready to bootstrap it:
./launcher bootstrap web_only (again with your new/own name)
Once bootstrapped, you can start
web_only (use your new name):
./launcher start web_only
When Discourse is ready, login and restore your site.
After this, everything worked again for me and my discourse installation was running again, but now in two separate containers.
If you do not care about the few minutes of downtime:
./launcher stop web_only && ./launcher rebuild data && ./launcher rebuild web_only
If you care about every minute of downtime:
./launcher bootstrap data && ./launcher destroy data && ./launcher start data
./launcher bootstrap web_only && ./launcher destroy web_only && ./launcher start web_only
It’s enough to rebuild
web_only and skip
data except when there is an upgrade to postgres or redis. Those happen on the order of once a year and you’ll see an announcement like PostgreSQL 13 update when it happens.
@pfaffman will one day create a topic about this, but until then, there is this: Managing a Two-Container Installation - Documentation - Literate Computing Support