Score:0

Docker bridge host gateway doesn't work

py flag

My default bridge network isn't working properly.

So I spinned up 2 containers, one is for mongodb and one is for ubuntu. These are the commands:

docker run -d ubuntu bash

docker run -d -p 27017:27017 mongo

These are the results for the default bridge inspect.

[
    {
        "Name": "bridge",
        "Id": "eb4d37858eeafc8e05061f4a28d6b6a5754ad92476f5361f9c624636a335d1b4",
        "Created": "2023-06-03T00:50:02.603305706+10:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "393c0b9bd82f7e7fd5469bae06016058a515cb9df7122b43a3a46c01cb28d992": {
                "Name": "ubuntu",
                "EndpointID": "8ed263215004e5b9deb18c23b4ff0aed2c5e60f862ac2d9118b9a6b9fb17100b",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "7d25013135cf2aaf4134c30ec4d87c3d5f88ade177c15461b0d5303e5ba530f3": {
                "Name": "mongoserver-test",
                "EndpointID": "b053f6f608675a23ef2c8541a0eb0a661270b49133596d901355bab4278ba166",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
 ]

In the ubuntu container I've installed nmap, and when I tried to check for port using nmap by using this command:

nmap -p 27017 172.17.0.1

It shows the port as "filtered", I believe that the mongodb server is accepting the incoming connections but couldn't respond. Why is this happening? How can I make it working? This result is happening on a linux environment. I've tested out in osx environment and its working.

Note: I'm trying to not to use --link as I'm trying to find a centralized way to do that without specifying --link all the time. And I don't want to use --network=host because this is just a test run, in the future I want to try to create a new container and make that as a centralized hub. Which I believe I can specify that by using:

docker run -d -p <new containerip>:27017:27017 mongo
Andreas Piening avatar
si flag
The command `docker run -d -p 27017:27017 mongo` should start the container listening on **localhost:27017**. Please can you check with `netstat -tulpn` if this is the case? Additionally, can you do a `telnet localhost 27017` to see if the mongo db server accepts connections?
learningdudz avatar
py flag
@AndreasPiening, running those commands on my host shows that 27017 does indeed opened on my host, I'm not too sure with the telnet command as I've never used it but this is what it shows up with `Trying 127.0.0.1... Connected to localhost. Escape character is '^]'.`, using `nmap -p 27017 localhost` shows that 27017 is open as well and of course if I change `localhost` to `172.17.0.1` it'll still shows them as open. But, once I enter to my ubuntu docker and test the port on the ip 172.17.0.1, it shows them as filtered.
learningdudz avatar
py flag
@AndreasPiening If this behaviour is something to be expected. Why does my osx environment work using the same methods and everything?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.