Docker Community Forums

Share and learn in the Docker community.

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.

Setting environment variables
In the Google Cloud Console, go to the VM instances page. …
Click the Create instance button to create an instance.
Under the Container section, select Deploy container image.
Click Advanced container options.
Under Environment variables, click Add variable.

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/