Real IP address on docker

How do I set docker up with a direct connection and ip address than is the same style as my router

I am afraid your question is too ambigous… How does “same style as my router” relate to docker?

docker uses NAT or something starting 127 or whatever
I need a static ip address using 192.168.1.X

What do you mean by “docker”?
The docker engine, a container, something else?

what do you think i mean
I mean the container

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.

This seems exactly what I need, Thank You

any idea
the container keeps restarting

I can’t say much without logs but it is possible that you could not sucessfully configure MacVLAN and your container does not have network connection so the process inside dies. Try to run the container interactively and find the cause:

docker run --rm -it imagename bash

If it doesn’t have bash, use any shell that it supports.

I removed


Edit: and it says status exited now

Could you find anything in the logs?


You should also make sure you have a process running in the container constantly. If you cannot find any error log messages and the container still exits, then your command in the container probably just finished its job and stopped.

It could be completely unrelated to the “Real IP address on docker” problem.

not much help here
no logs
the container will not start and the process running should be bash

Bash will not keep the container alive unless you run it in interactive mode:

docker run -i -t IMAGE_NAME bash

This is why I suggested it before to test the container

This was fixed by running the container in interactive mode