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