SQLCMD cannot connect to SQL instance (Container to Container)

Please assist.

I have two docker containers - running in the same network.
The 1st one hosts a sql server instance - which I can access successfully from the host.

However, a 2nd container - one same network - cannot access the sql instance in the 1st container?

I installed mssql-tools and now have sqlcmd tools on the 2nd container and this is the error I receive: I tried the server name, ip address - but to no avail ;-(

# ./sqlcmd -H 172.19.0.2,1433 -U sa -P Admin3970#xx -d TestDb
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…

# ./sqlcmd -H localhost,1433 -U sa -P Admin3970#xx -d TestDb
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…

# ./sqlcmd -H sqlx1,1433 -U sa -P Admin3970#xx -d TestDb
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…

# ./sqlcmd -H sqlx1.myne,1433 -U sa -P Admin3970#xx -d TestDb
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…

I just go it working, but have another connection issues :slight_smile:

./sqlcmd -S 172.19.0.2 -U sa -P Admin3970#xx -d TestDb

1> USE TestDb
2> GO
Changed database context to ‘TestDb’.
1> SELECT * FROM tblList
2> GO
Id Name


      1 Cat
      2 Dog
      3 Rabbit

(3 rows affected)
1>