I need to use two containers together: one with Tomcat and another with a Database.
I have created the following yaml file which describes the services:
Use the alias "db" that you have defined in file to refer to the database host name.
Containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.
Source: https://docs.docker.com/compose/compose-file/compose-file-v2/#links