Reputation: 32296
When I link the exposed ports within container to the host port, everything works as expected...
docker run -d -p 9200:9200 -p 9300:9300 elasticsearch
curl -XGET localhost:9200/_cat/indices
But when I do not use ports option with run command, I am not able to connect.
# docker run -d elasticsearch
# docker inspect 87c6bcb3b67e | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.3",
"IPAddress": "172.17.0.3",
# curl -XGET 127.17.0.3:9200/_cat/indices
curl: (7) Failed to connect to 127.17.0.3 port 9200: Connection refused
I can log-in to container and access elasticsearch without any problem. like this...
# docker exec -it 2ec9026b755e bash
# curl -XGET localhost:9200/_cat/indices
Is there any way to access elasticsearch from host even if the ports are not linked?
Upvotes: 0
Views: 71
Reputation: 1323145
Is there any way to access elasticsearch from host even if the ports are not linked?
Normally no: that is what container are for: providing isolation. That allows you to launch many containers, each one running on the same port.
Upvotes: 1