Docker swarm stop spin up containers at 250
I just figure it out. The problem is not with the service or the swarm, it's with the network.

When I use driver: overlay the default subnet is 10.0.0.0/24 which result in 254 address. So I change the mask in the subnet, to 22, which result in 1022 address, I added:

ipam:
  config:
    -subnet: 10.0.0.0/22


And now the network section in the docker-compose file looks like this:

networks:
  web:
    driver: overlay
    ipam:
      config:
        - subnet: 10.0.0.0/22