# Linking containers for a multiple container setup

**URL:** https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867
**Category:** Self-hosting
**Created:** [October 7, 2014, 6:04am UTC](https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867 "2014-10-07T06:04:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nx2zdk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nx2zdk/32/115006_2.png) [@nx2zdk](https://meta.discourse.org/u/nx2zdk)
#### Post date: [October 7, 2014, 6:04am UTC](https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867/1 "2014-10-07T06:04:50Z")

</div>

**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`](https://docs.docker.com/userguide/dockerlinks/) 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`

---

<div class="post-metadata">

### Author: ![acao](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@acao](https://meta.discourse.org/u/acao)
#### Post date: [December 31, 2014, 5:33am UTC](https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867/4 "2014-12-31T05:33:30Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![ernsheong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ernsheong/32/108797_2.png) [@ernsheong](https://meta.discourse.org/u/ernsheong)
#### Post date: [January 9, 2015, 6:23am UTC](https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867/5 "2015-01-09T06:23:12Z")

</div>

Maybe [Use multiple Docker containers without exposing ports](https://meta.discourse.org/t/how-to-use-docker-multiple-containers-without-exposing-ports/22283) 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`
