Is there a way for containers on two different overlay networks to communicate?

As an example take container 1 ( c1 ) and container 2 ( c2 ) on the overlay networks 172.0.0.0/24 and 192.0.0.0/24 respectively.

Is there a way to customize the two overlay networks - perhaps on creation with some custom settings - to allow communication from c1 to c2 and vice-versa?

So far, I’ve tried having a vyos router container ( 2stacks/vyos image) with the routing rules configured within it. In this instance, I would have to also set routing rules within the c1 and/or c2 to allow the following path:

c1 >>> vyos-container >> c2 .

However, this is not scalable as it depends heavily on the specific constraints of the Docker images used for c1 and c2 and involves entering the container to make changes.

I’ve also tried to set the --gateway IP when running docker network create to point to an IP that I will eventually assign to the vyos router to achieve the path mentioned above. However, Docker errors when I try to assign the --gateway IP address to any subsequent containers.

Is there a less manual and more general/reusable way to achieve this using default Docker commands?

I’m coming from a software background with more limited networking knowledge so I may be missing something simple.