Setting up a macvlan in docker has an irritating fact that the host cannot be reached from the container and the host itself cannot reach the container.
Most people propose to add a second macvlan to the ethernet interface to allow routing between docker container and host. The drawback is, that this setup involves manual work for the container user.
I think I came up with an elegant solution (at least for me) to solve this;
a) add a second (default bridge) network to the container (see A & B)
b) add a routing rule inside the container to route trafic to the host via this second interface -> allow container to host traffic (see C)
c) As usual, expose ports on this default interface -> allows host to container traffic
Benefits:
- Can be configured completely inside a container (i.e. startup script) and with a docker compse file ==> easy for users!
Example / proof of concept for a host at 192.168.0.22 hosting a docker container:
B) The resulting network configuration
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.