Create swarm and overlay network with docker-compose

I’m a bit confused about how to do this. I can manually create a swarm and overlay network, and then use “service create” to start various services. The containers get distribute across the nodes in the swarm as expected.

Now, I’m trying to put all my services into a compose file. I am able to start up all my services using compose, but my issue is that it will only deploy the services to the node where I run “docker-compose up” on. I notice that when I run compose, it sets up a default bridge network. I’m sure this wouldn’t be sufficient for multi-hosts. Thus, I would also need compose to create an overlay network for me.

I don’t see any compose examples on how to set up a swarm, setup the overlay network, and then deploy the services across the entire swarm.

Anyone have pointers? I tried searching around, and couldn’t find anything

EDIT:
Other bits of information. I am able to use Kubernetes with a .yml file to achieve what I’m trying to do. Basically, with Kubernetes I setup my cluster, setup the overlay network, then run the .yml file, and everything. I’m looking to do a similar thing with compose. For now, it’s ok with I have to setup the swarm and overlay manually, but I do need compose to be able to distribute my containers across multiple nodes.

Hi,

I found this link to be pretty comprehensive and let me run docker stack deploy to auto generate the overlay networks for the services I define. Did you miss it?

I see,

I was working with Version 2 format, I’ll give this a try when I have a chance.