# Kibana docker image doesn't connect to elasticsearch image

**URL:** https://discuss.elastic.co/t/kibana-docker-image-doesnt-connect-to-elasticsearch-image/79511
**Category:** Kibana
**Created:** [March 21, 2017, 9:44pm UTC](https://discuss.elastic.co/t/kibana-docker-image-doesnt-connect-to-elasticsearch-image/79511 "2017-03-21T21:44:25Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![jarpy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jarpy/32/51290_2.png) [@jarpy](https://discuss.elastic.co/u/jarpy)
#### Post date: [March 23, 2017, 11:24pm UTC](https://discuss.elastic.co/t/kibana-docker-image-doesnt-connect-to-elasticsearch-image/79511/4 "2017-03-23T23:24:26Z")

</div>

Hi. This one is all about [Docker Networking](https://docs.docker.com/engine/userguide/networking/).

There are some steps involved in getting Docker to establish network links and name resolution between containers. It's one of the reasons I tend to recommend getting started with Docker Compose, since it takes care of some of these details.

The Kibana image tries, by default, to connect to a host/container called `elasticsearch`. However, the Docker operator must arrange for that name to make sense, and for there to be a network connection between the two containers. The latest, and probably simplest technique that Docker provides for this is "[user-defined networks](https://docs.docker.com/engine/userguide/networking/#user-defined-networks)".

Here is a minimal, working example of using user-defined networks with `docker run`:

```auto
docker network create elastic
docker run --network=elastic --name=elasticsearch docker.elastic.co/elasticsearch/elasticsearch:5.2.2
docker run --network=elastic -p 5601:5601 docker.elastic.co/kibana/kibana:5.2.2

```

Here, we create a user-defined network, ensure that both containers are attached to it, and crucially, make sure that the Elasticsearch container is named `elasticsearch`, just as Kibana expects. Docker will then ensure that the hostname `elasticsearch` resolves to the correct IP address for any container on that network.

If we don't do any of that, then Docker places the containers on the "default bridge network". From their documentation:

> Docker does not support automatic service discovery on the default bridge network. If you want to communicate with container names in this default bridge network, you must connect the containers[...]

Also note that trying to refer to the Elasticsearch container as `localhost` won't work either. Every container thinks that it is, itself, `localhost`. When you are inside the Kibana container, `localhost` actually _is_ the Kibana container.

Hopefully that helps to get you started. I highly recommend the [Docker Networking  
docs](https://docs.docker.com/engine/userguide/networking/) for more details and fancy tricks.

---

_[View the full topic](https://discuss.elastic.co/t/kibana-docker-image-doesnt-connect-to-elasticsearch-image/79511)._
