Linking containers for a multiple container setup

(nx2zdk) #1

Multiple Container setup

If you would like to connect web-only and data Discourse docker containers.
There is optional setting for this, which is, you could specify a links key in container configuration (yaml file) to link those containers together ( i.e. linking web-only and data container ).
This way is also known as Docker --link flag.

If you are trying to link database container to your web container

Add the following section in containers/web.yml

  - link:
      name: data
      alias: db

That will be transformed into --link data:db

Bootstrap web_only container gets PG::Error for separated data container
Discourse High Availability
Avoid need to rebuild web container after reboot?
PG::ConnectionBad: could not connect to server: Connection refused
(Acao) #4

I’ve been trying this approach, as I’m familiar with using --link and found this in the web-only config, but then what are you supposed to indicate for DISCOURSE_DB_HOST/REDIS_HOST etc? db:migrate keeps failing on bootstrap for me, even though the data container is already running!

(Jonathan Lin) #5

Maybe How to use Docker multiple containers without exposing ports is what you are looking for, i.e. if you link to the data container then both DISCOURSE_DB_HOST and DISCOURSE_REDIS_HOST should both be set to data