How can I control how many services per host?

What’s the simplest way (1.12 is fine) to get this running on AWS so that there is 1 total main service and 50 node services, such that there exists only 2 node services on each host (or EC2 instance)? There are so many options out there and I’d like to use docker swarm, but I can’t seem to figure out how to control how many services per host. Bonus for autoscaling the ec2 instances, so I don’t have to create 25 of them by hand (which I can probably just script). The docker-compose.yml looks something like:

main:
  image: example/main
  ports:
    - "333:333"
node:
  image: example/node
  links:
    - main

Also these “node” services don’t need to be load balanced and I don’t care if they go down. They all report to the “main” service. And perform some quick job. After that job is complete I’m going to remove all nodes. Is docker swarm mode still appropriate?

I recommend trying out Docker for AWS. Sign up here: https://beta.docker.com/ and ping us at docker-for-iaas@docker.com so that we can get you in. That’ll take care of auto-creating the swarm.

The you’d create a DAB bundle from your compose file and deploy that as a stack. Scale the main service to 1 and the node to 50. The distribution may not always be perfect at two node containers per worker node, but it’ll even out over time.

Details on DAB here: https://blog.docker.com/2016/06/docker-app-bundle/