When I use the --scale parameter to start multiple instances, how do I get the number of the current instance?

When I use the --scale parameter to start multiple instances, how do I get the number of the current instance?
Because I need to get the number to set the machine number in my snowflake algorithm.
About the snowflake: https://github.com/twitter-archive/snowflake/tree/snowflake-2010

Check: docker service ls