Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access external URLs from within Docker Container

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"]
like image 410
Dorian McAllister Avatar asked Sep 15 '25 09:09

Dorian McAllister


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.

like image 151
Dorian McAllister Avatar answered Sep 17 '25 01:09

Dorian McAllister