user11872360
user11872360

Reputation:

Issue running elasticsearch docker with 2 different version and port numbers

I am new to docker and already running another ES with docker which is using defaults port, now I need to run another version of ES on my local machine, for which I followed the instructions mentioned in:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

I just changed the default ports by starting my docker using below command:

docker run -p 9500:9500 -p 9600:9600 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.1

now this brings up the container but I am not able to access it on http://localhost:9500/.

I think issue is with the tcp port 9200 which is coming in case of ES7.x docker, although as mentioned in my run command, I changed default port of 9200 to 9500.

O/P of both the docker containers running in my system:

CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS                                                                NAMES
5463d48854bd        docker.elastic.co/elasticsearch/elasticsearch:7.5.1   "/usr/local/bin/dock…"   17 seconds ago      Up 16 seconds       9200/tcp, 0.0.0.0:9500->9500/tcp, 9300/tcp, 0.0.0.0:9600->9600/tcp   loving_thompson
5897f09dfe2b        elasticsearch:es                                   "/docker-entrypoint.…"   2 months ago        Up 9 days           0.0.0.0:9200->9200/tcp, 9300/tcp                                     es

Upvotes: 3

Views: 1099

Answers (1)

baitmbarek
baitmbarek

Reputation: 2518

You should try to change your docker run command to the following:

docker run -p 9500:9200 -p 9600:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.1

This will bind the port 9500 on your host with container's port 9200 (which is the default http port for elasticsearch)

Upvotes: 4

Related Questions