# Linking containers

**URL:** https://meta.discourse.org/t/linking-containers/13694
**Category:** Self-hosting
**Tags:** hosting
**Created:** [March 13, 2014, 2:22pm UTC](https://meta.discourse.org/t/linking-containers/13694 "2014-03-13T14:22:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![resure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/resure/32/107229_2.png) [@resure](https://meta.discourse.org/u/resure)
#### Post date: [March 13, 2014, 2:22pm UTC](https://meta.discourse.org/t/linking-containers/13694/1 "2014-03-13T14:22:45Z")

</div>

What is correct way to connect web-only and data Discourse docker containers?

There is note about `DISCOURSE_HOST_IP` in readme, but how should we specify that variable in container config yml file? Can we just [link that images together?](http://stackoverflow.com/questions/18460016/connect-from-one-docker-container-to-another)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 13, 2014, 11:26pm UTC](https://meta.discourse.org/t/linking-containers/13694/2 "2014-03-13T23:26:52Z")

</div>

What you do is expose the port on the host, then you can easily connect to it from any container.

The “expose” section in the yml takes care of it:

```plaintext
expose:
  - "5432:5432"
  - "6379:6379"
  - "2221:22"

```

Then all you need to do is plug in local machine ip here:

> <https://github.com/discourse/discourse_docker/blob/master/samples/web_only.yml#L19-L26>

---

<div class="post-metadata">

### Author: ![Sander78](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sander78/32/296615_2.png) [@Sander78](https://meta.discourse.org/u/Sander78)
#### Post date: [March 30, 2014, 4:56pm UTC](https://meta.discourse.org/t/linking-containers/13694/3 "2014-03-30T16:56:59Z")

</div>

Hmm.. but what is `YOUR_IP_ADDRESS` here? The external IP of the server (I guess not), or the variable `DISCOURSE_HOST_IP`?

I want to use `web_only.yml` and have a central redis and postgresql service on my server running.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 31, 2014, 2:19am UTC](https://meta.discourse.org/t/linking-containers/13694/4 "2014-03-31T02:19:27Z")

</div>

It really depends on how you set up your server. Try running `ifconfig`

I think you should be able to use docker0 for this. `172.17.42.1`

---

<div class="post-metadata">

### Author: ![Sander78](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sander78/32/296615_2.png) [@Sander78](https://meta.discourse.org/u/Sander78)
#### Post date: [March 31, 2014, 7:14am UTC](https://meta.discourse.org/t/linking-containers/13694/5 "2014-03-31T07:14:48Z")

</div>

You’re right, it’s that IP address. On both sites. Thanks.

---

<div class="post-metadata">

### Author: ![Sander78](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sander78/32/296615_2.png) [@Sander78](https://meta.discourse.org/u/Sander78)
#### Post date: [March 31, 2014, 9:31am UTC](https://meta.discourse.org/t/linking-containers/13694/6 "2014-03-31T09:31:52Z")

</div>

Last question (I think): what to use for `DISCOURSE_DB_SOCKET`? It should point to the socket of the host, but will it have access to it?

And why set a pasword if not setting a user variable?
