I know that using driver host the container would use the same network namespace but I would like to get something as in "Bridged Mode" of VirtualBox. I mean: that container to be in the same subnet that host but using different namespace. Is that possible?
-
On Linux you can assign a static IP address from host's subnet to a container. All traffic to that address will be directed to the container. If that is what you want to achieve, see [this](https://stackoverflow.com/a/64643963/11344502) my answer for an example. – anemyte Oct 06 '21 at 19:58
1 Answers
I had the same issue. I was trying ping to my container (centos) from my host but it wasn't working.
Here is what I did to solve this. I can't guarantee any stability or security so follow this at your own risk.
My Set-Up:
I have 2 different VMs (Ubuntu) running on my Vmware workstation on my host (Windows 10). I configured to use "NAT" for both my VMs.
My first ubuntu VM is running with default settings.
My second ubuntu VM: is the Docker Host. I've first installed docker on this VM.
After docker is successfully installed on the second ubuntu VM, i've configured the following settings:
a. Create a macvlan docker network as follows:docker network create -d macvlan -o parent=eno1
--subnet 192.168.1.0/24
--gateway 192.168.1.1
--ip-range 192.168.1.192/27
--aux-address 'host=192.168.1.223'
mynet \
note: eno1 is the physical interface on your VM. Also, change the IP settings according to your LAN settings.
On the Second VM (Ubuntu docker host) configure the interface to communicate with your docker container:
ip link add mynet-int link eno1 type macvlan mode bridge
After that configure the IP address and bring the interface UP:
ip addr add 192.168.1.223/32 dev mynet-int
ip link set mynet-int up
Finally, configure the route to your container
ip route add 192.168.1.192/27 dev mynet-int
By following these steps I was able to put the container and the host(ubuntu VM) on the same network. Pings were successful back and forward.

- 11
- 1