DNS resolve sql server Service Containers failed in self-hosted agent pipeline
created a sql server Service Containers in a linux self-hosted agent
services:
mssql:
image: 'mcr.microsoft.com/mssql/server:latest-ubuntu'
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
used shell to check connectivity is successful.
steps:
- script: |
nc -zv localhost 1433
nslookup -v localhost
Connection to localhost 1433 port [tcp/ms-sql-s] succeeded! Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: localhost Address: 127.0.0.1 Name: localhost Address: ::1
but in later task alway got connection refused
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused (Connection refused). Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
does anyone who has the same situation?