The current Docker hub image for ElasticSearch for version 2 is configured to only listen to loopback devices by default, ignoring non-loopback devices. This makes it difficult to use the container for development.
If your Docker VM is running on 192.168.99.100, with port-forwarding set to port 3278 (use ‘docker inspect’ to verify this), when checking for connectivity from outside of the container, you will end up with the following:
curl: (7) Failed to connect to 192.168.99.100 port 3278: Connection refused
One workaround is to force ElasticSearch to mount to non-loopback devices:
A configuration file for the container is expected to be created and named elasticsearch.yml, located at /usr/share/elasticsearch/config
Either a bind-mount location for the configuration file (docker run -d -v), or add a configuration elasticsearch.yml file directly into the filesystem.
For example, to write to the filesystem from the container’s command shell:
echo 'network.host: _non_loopback_' > /usr/share/elasticsearch/config/elasticsearch.yml
Restart service or container and it will take effect.