0

Running CentOS 7.

I have a container that exposes the port 15672. It runs the management panel for rabbitmq, so curl should fetch the login page if I just ran curl on the address.

This is the output of docker ps -a:

4e183234a288 rabbitmq:3.7-management  ... 4369/tcp, 5671-5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:32768->15672/tcp

My IP for this box is (by running docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' 4e18) is 172.24.0.3

However, curl gives me the following error:

[root@server work-dir]# curl 172.24.0.3:32768
curl: (7) Failed connect to 172.24.0.3:32768; Connection refused

However, if I use the gateway (fetched using docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' 4e18), it works:

[root@server work-dir]# curl 172.24.0.1:32768
<!doctype html>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<html>
  <head>
    <title>RabbitMQ Management</title>
...

This is the ouput of netstat -nr:

[root@server mitter-equities]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         184.175.83.1    0.0.0.0         UG        0 0          0 ens224
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 ens224
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
172.20.0.0      0.0.0.0         255.255.0.0     U         0 0          0 br-093cf4da3140
172.24.0.0      0.0.0.0         255.255.252.0   U         0 0          0 br-18dc05c33da8
184.175.83.0    0.0.0.0         255.255.255.0   U         0 0          0 ens224

The network that the container runs in is br-18dc05c33da8 which is declared separately with a subnet 172.24.0.0/22.

What I really want is my local port to be bound to this bridge network. However, when I do that:

[root@server ~]# curl localhost:32768
curl: (56) Recv failure: Connection reset by peer

When running with the exact same setup on my local machine (Arch Linux), I am able to curl using both the gateway and the localhost (same port that docker picked).

My question is:

  1. How do I get CentOS to bind that to the local port? I want this port to be exposed publicly as it exposes an external service. The port 32768 is exposed (right now it is an ephemeral port that docker picks up. I am just testing this setup. Once it works I will fix the port number), but traffic from outside cannot reach the docker container.
  2. Why does the IP of the container not work? Doesn't my system already know that for IP addresses in 172.24.0.0/22 the gateway is 172.24.0.1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.