Configure container like a member of the host network

Hello!

I’m using Docker for Windows with a Linux container.

Is it possible to configure the container to act as if it was a computer on the host’s network? That is, no port forwarding from host to container, no separate subnet etc.

So far, I tried to go far a macvlan network driver, but eventually the host could not ping the container and the container could not ping the host.

What am I missing?

Thanks in advance!

The restriction that macvlan interfaces can not directly communicate with their parent interface - this a security feature of your hosts kernel and NOT a restriction introduced by docker.

I did run very complex orchestarted container setups in my job and NEVER needed macvlan once in 6 years. Usualy people trying to enforce old habits from the vm world to the container world are the only ones convinced that macvlan is the right and only solution :face_with_hand_over_mouth:

If macvlan is not the way to go, how can I achieve the scenario that I described in my original post?

Well what you WANT can done with MACVLAN (there is even a workaround for the limitation) or IPVLAN though it doesn’t necessarily mean that it is what you NEED or what a experienced docker user would use.

Feel free to use whatever works. I am quite sure MACVLAN was discussed in this forum plenty of times and the forum’s search function will bring up some valuable details. Good luck!

I would not have posted this question here if I had found a solution elsewhere.

Obviously, my scenario is not a common need. Nonetheless I’d like to know if it is possible and how.

Earlier version of the macvlan documentation actualy had all the relevant information and even covered the required workaround to bypass the kernel limitation. The current docs are a slimed down version that only shows the commands to create a docker network with the macvlan driver. Its a shame.

Now you have to rely on blog posts like this: https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/