Hi. This one is all about Docker 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".
Here is a minimal, working example of using user-defined networks with
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 for more details and fancy tricks.