Linking containers for a multiple container setup

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.

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

Add the following section in containers/web.yml

links:
  - link:
      name: data
      alias: db

That will be transformed into --link data:db

3 Likes

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!

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