Purpose of creating link in docker compose

What is the purpose of creating link to locust with all the prediction containers when we are writing the host uris manually in python file used by locust container? What does the link command actually do in docker Compose

The link flag ensures that the python file executing inside the locust container can access other containers by id rather than knowing other the container ip. You can read about it here.