To link multiple containers in a Discourse Docker setup, you can use the links key in the container configuration (yaml file). This is similar to Docker’s [--link][https://docs.docker.com/userguide/dockerlinks/] flag.
To link a database container to a web container, add the following to containers/web.yml:
links:
- link:
name: data
alias: db
This will transform into --link data:db. When linking to the data container, set both DISCOURSE_DB_HOST and DISCOURSE_REDIS_HOST to data, as ernsheong suggests. For a more detailed guide, see this meta Discourse post.
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
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!