Nena
Nena

Reputation: 701

Centos VM with Docker getting host unreachable when trying to connect to itself

I have Docker running on a Centos VM, with bridged network. running

ifconfig

shows that my VM gets a valid IP address. Now I'm running some software within a docker container/image (which works within other docker/networking configurations). Some of my code running in the docker container uses SSL Connection (java) to connect to itself. In all other run configurations, this works perfectly. But when running in bridged mode with Centos VM and docker-compose, I'm getting an SSL Connect exception, error: Host unreachable. I can ping to and ssh into the VM with the same IP address and this all works fine. I'm sorry that I can't post actual setup/code and scripts as it's too much to post and it's also proprietary.

I'm baffled by this - why am I getting Host Unreachable in the aforementioned configuration?

Upvotes: 11

Views: 6876

Answers (2)

sercasti
sercasti

Reputation: 580

My solution was to switch to an Ubuntu VM, because switching my docker compose to the default "bridged" network broke my aliases, which I really needed

The only remaining question here is why after configuring firewalld, a user-configured network on docker-compose cannot access the external IP, forcing us to switch to the default bridged network

Upvotes: 0

Nena
Nena

Reputation: 701

FYI, I resolved the problem on centos by using the default "bridged" containers provided by Docker, but adding the following to my firewalld configuration:

firewall-cmd --permanent --zone=trusted --add-interface=docker0
firewall-cmd --reload
service firewalld restart

You might also need to open up a port to allow external communication, like so:

firewall-cmd --zone=public --add-port=8080/tcp --permanent

Upvotes: 13

Related Questions