Hello! Thanks for your interest in the Elasticsearch Docker images.
I think the main issue you are having here is the use of --publish-all. You should replace it with -p 9300:9300 for the transport port as --publish-all will randomly allocate an external port for your containers.
You can inspect the container ports with docker port elasticsearch-container.
I have prepared a Vagrantfile (uses VirtualBox) to use for replicating your scenario. This creates an elasticsearch.yml with your custom config params under /home/vagrant.
Following vagrant up && vagrant ssh m01, if I docker run using --publish-all:
vagrant@m01:~$ docker run --ulimit memlock=-1:-1 --name elasticsearch-container -v $PWD/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -e cluster.name=docker-cluster -e bootstrap.memory_lock=true -e node.name=main01 -e network.publish_host=192.168.124.101 --publish-all -p 9200:9200 -d docker.elastic.co/elasticsearch/elasticsearch:5.5.0
1051cc374b32f14d977c7eb8757b666f857b91b7ab68c37736a7b2f93e66aa7e
vagrant@m01:~$ docker port elasticsearch-container
9200/tcp -> 0.0.0.0:9200
9300/tcp -> 0.0.0.0:32768
vagrant@m01:~$ nc -v localhost 9200
Connection to localhost 9200 port [tcp/*] succeeded!
^C
vagrant@m01:~$ nc -v localhost 9300
nc: connect to localhost port 9300 (tcp) failed: Connection refused
nc: connect to localhost port 9300 (tcp) failed: Connection refused
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.