How to connect to SQL Sever docker container from another container?
Docker has a DNS server built in, and containers connect to each other by the container name. In your case you named the SQL Server container mssql
so that's the server name you need to put into your connection string for the .NET app: Server=mssql;Database=student;User Id=sa;Password=!Abcd123;
.
Check out the .NET Core album viewer sample on GitHub, which uses Docker Compose to define a multi-container app.
I resolved the issue by inspecting container network firstly then find the network IP and put to appsetting.json
"ConnectionStrings": {
"DefaultConnection": "Server=172.17.0.2;Database=VehicleKey;User Id=sa;Password=p@ssW0rd;"
}
find name of SQLSERVER