Unable to connect to SQL server inside docker container

So, I have 2 docker containers (inside one of them I have an application, inside another sqlsrv).

I tried to connect from the docker-container with application to the sql server database inside another container.

For this I did:

 [email protected]:/# sqlcmd -S 172.17.0.1 -U sa -P test

After I got an issue:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

When I used this option inside docker-container with mssql database without -S 172.17.0.1 it works fine.
Any ideas how to connect from container with application to the container with database via sqlcmd?

Update

I mistaken, I used pass this command from docker-container with database.
Still have a problem with connection from app to the database

Source: StackOverflow