My NAS is where I run my containers. It sits on 192.168.1.23
on my network.
I am running a few containers inside a user-defined network. Here is the docker network inspect
(I've removed the containers manually) :
[
{
"Name": "traefik2_proxy",
"Id": "fb2924fe59fbb0436c72f11cb028df832a473a165162ecf08b7e3a946cfa2d3c",
"Created": "2020-05-13T23:23:16.16424119+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.90.0/24",
"Gateway": "192.168.90.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]
I have a specific container which is in that network at IP address 192.168.90.16
for which I have exposed the 9118
port using the following in my docker-compose :
ports:
- target: 9118
published: 9118
protocol: tcp
This is the portainer screenshot :
I was expecting to be able to connect to that container using 192.168.1.23:9118
but I tried to no avail.
What am I missing ? Which setting do I need to change for that container to be visible at that port on my NAS IP address ?
Usually Docker uses the default 172.17. 0.0/16 subnet for container networking.
On Docker for Linux, the IP address of the gateway between the Docker host and the bridge network is 172.17. 0.1 if you are using default networking. Do you see the problem already? They are different, so you cannot simply run docker-compose up -d and all operating systems behave the same.
Docker Container IP Address By default, the container is assigned an IP address for every Docker network it connects to. And each network is created with a default subnet mask, using it as a pool later on to give away the IP addresses. Usually Docker uses the default 172.17. 0.0/16 subnet for container networking.
This network is called a "docker network". Think of docker network as a pool of available IP addresses. If two containers take on IP addresses from the same pool, they're going to be able to communicate with each other.
Container IP addresses are an essential part of networking docker containers. Typically, containers are assigned an IP address for every network they connect. On the other hand, you can also manually connect a docker container to the bridge network using the command below. $ docker run -dt rabbitmq
Think of docker network as a pool of available IP addresses. If two containers take on IP addresses from the same pool, they're going to be able to communicate with each other. There are mainly two types of networks, the default or predefined networks and the user-defined networks. Ignore the last two and focus on the first network.
The port that the container was listening to was incorrect. I needed to modify the ports
configuration to:
ports:
- target: 9117
published: 9118
protocol: tcp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With