How to visit elasticsearch in docker in another docker?

I deploy elasticsearch in docker with below command:

sudo docker run --name es1 -p 6200:9200 -p 6300:9300 -e "xpack.security.enabled=false" -e discovery.type=single-node -e "ES_JAVA_OPTS=-Xms2048m -Xmx2048m" docker.elastic.co/elasticsearch/elasticsearch:5.5.3

the host ip where the docker container run is hostip
the inet addr of docker0 is 172.17.0.1
docker inpect above ES container and its ip is: 172.17.0.5

I run command in host directly:
curl -XGET 'hostip:6200'
then I get result

I run command in another docker which is deployed on the same host with above ES:
curl -XGET 'hostip:6200'
nothing get and the visit will timeout

I run command in another docker which is deployed on the same host with above ES:
curl -XGET '172.17.0.1:6200'
nothing get and the visit will timeout

I run command in another docker which is deployed on the same host with above ES:
curl -XGET '172.17.0.5:9200'
then I get result

I run command in another host which is diff with the host above ES deployed:
curl -XGET 'hostip:6200'
then I get result

I run command in another docker which is deployed on the diff host with above ES:
curl -XGET 'hostip:6200'
then I get result

so my question is: how can I visit this ES container with hostip:6200 from another container which deployed on the same host ?

--net=host is not the choose under my condition.

can anybody help to take a look at this issue please?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.