How to Implement VRF (Virtual Routing and Forwarding) for Docker Containers?

Hello Everyone,

I’m currently working on a project where I need to implement VRF (Virtual Routing and Forwarding) support for Docker containers. The goal is to isolate network traffic for different containers, ensuring that each container operates within its own VRF instance.
I noticed that there have been many discussions on this topic in the past (a few years ago), but I haven’t been able to find complete information anywhere. All I could find is below

This only ensures dockerd is using a specific vrf, but containers are not.

I have a few specific questions:

  1. Is VRF support natively available in Docker, or does it require additional configuration or third-party tools?
  2. What is the best approach to associate Docker containers with specific VRF instances?
    For example, should I configure VRF on the host and then map it to the containers, or is there a better method?

Did you get any answers?

No, not yet. Currently, we are using host mode and command “ip vrf” to use particular VRF.

I am afraid there are not many (maybe even none?!) users in the community that have experience with VRF and are able to help out.

The only post we had over the years were posts from users asking for help, but all of them remained unanswered.

I found a github issue stating that vrf is not supported: Docker does not handle a VRF setup · Issue #698 · docker/for-linux · GitHub

Update: forget the GitHub Issue Link, it is for Docker Desktop on Linux, where the docker engine runs in a utility vm. I was wrong: the issue is not about Docker Desktop, it is about Docker CE on Linux.