Real IP address on docker

People often use the name “Docker” wrong. This is why we need to make sure we think of the same thing before the answer. Even if something is obvious to you we might have something else in our mind, so yes, youl will probably have some questions you feel unnecessary. :slight_smile: Make sure, you are clear enough to people reading and answering a lot of questions every day and avoid using “whatever” especially after an incorrect example like

but it’s okay, it was close :slight_smile:

Although I think I understand what you need which is probably MacVLAN

You could actually configure Docker (not just an individual container) to use a private subnet like that without having that “direct connection” you probably want.

So if I understand you, you actually whant your router to give an IP address to your container from the LAN network so you don’t need port forwards to access a webservice listening in a container on an other host and you want to make it static, because you don’t want to find out the IP of the container every time it is recreated. I just hope I understood you, but if I did, this is what helps us to understand immediately your goal. Since I didn’t remember how you would set a static IP on MacVLAN, I searched for “docker static macvlan” on Google and the first result was an other topic on this forum:

I haven’t tried it though, but it looks right.

When you start to configure it, keep in mind that it is not always the best solution. I quote only the three points but please, read the whole section.

  • It is very easy to unintentionally damage your network due to IP address exhaustion or to “VLAN spread”, which is a situation in which you have an inappropriately large number of unique MAC addresses in your network.
  • Your networking equipment needs to be able to handle “promiscuous mode”, where one physical interface can be assigned multiple MAC addresses.
  • If your application can work using a bridge (on a single Docker host) or overlay (to communicate across multiple Docker hosts), these solutions may be better in the long term.