Docker swarm route only when replica has finished starting
So there is a healtcheck section for the deployment of the compose file which one can use to make sure a container is healthy or not.
healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3482/monitoring/health"] interval: 10s timeout: 5s retries: 3 start_period: 1m
This will do it and make sure a container will be used first if the health api returns a valid response.