

When running Elasticsearch, you will need to ensure it publishes to an IP address that is reachable from outside the container this can be configured via the setting network.publish_host.įor the discovery between the nodes you have to configure Zen Discovery via the settings .hosts and _master_nodes.Įxample: docker run -d -p 9200:9200 -p 9300:9300 elasticsearch:2 \ You can achieve that using the port mapping. This bridge will automatically forward packets between any other network interfaces that are attached to it and also allow containers to communicate with the host machine as well as with the containers on the same host.īy default, Docker containers can make connections to the outside world, they connect via the docker0 interface but the outside world cannot connect to containers.Įxternal connectivity is provided by IP forwarding and iptables rules. When you add a container, each of them will have its own virtual Ethernet interface connected to the docker bridge docker0 and it will have an IP address allocated to the virtual interface. We can check the details of the default bridge network using the following command: The bridge network is the default network in Docker. In general we recommend against using it for security reasons, but it can be useful when you need to get the best network performance because it is as fast as normal host networking. It will allow you to change the host network from within the container and if you have an application running as root and it has a vulnerability, there is risk of unsolicited remote control of the host network via the the Docker container. If you use -net=host then the container will use the host network and this can be dangerous. It completely disables networking, which is not useful when running an Elasticsearch cluster.

We can list all of them using the following command:

There are different ways to setup networking in Docker and by default three network types are presented.

You can create your own image by following our recommendation in the blog How to make a Dockerfile for Elasticsearch. The development and production of this Docker image is not affiliated with Elastic. Note: In this blog we will reference the Elasticsearch image found on the Docker Hub. In this blog we’ll talk about network considerations when using Docker with an Elasticsearch cluster.
