Unable to access external URLs from within Docker Container

Viewed 6085

I'm trying to access an external URL from within my Docker Container running on an AWS EC2 Instance.

Though I'm able to CURL from the EC2 Instance - the same CURL doesn't work from within the Docker container. Essentially this CURL works in the EC2 Instance but NOT within the Docker Container. Why would that be?

curl https://elasticsearch.myorg.com

Dockerfile:

FROM docker.elastic.co/kibana/kibana:6.5.0
ENV ELASTICSEARCH_URL=https://elasticsearch.myorg.com
EXPOSE 5601
CMD ["/usr/local/bin/kibana-docker"]
1 Answers

So after a LOT of trial and error, I finally figured out the problem. It looks like running the docker image using the standard:

docker run -d -p 5601:5601 my-kibana-image:1

doesnt suffice. The host resolution to elasticsearch (which is an external host) ONLY works when I change the network configuration from the default to "host". Doing this

docker run --net=host -d -p 5601:5601 my-kibana-image:1

finally fixed the issue and the kibana container instance was FINALLY able to talk to elasticsearch!!! Kibana bootstrapped correctly and I was able to bring it up fine at this point.

Related