Docker容器连接到MSSQL

时间:2017-10-19 04:03:51

标签: docker docker-compose

我是码头工人的新手。这是我想要做的。 docker容器中有web服务,我希望它能访问现有的MSSQL服务器。

这是连接字符串

version: '3'
    services:
      pricing.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ConnectionString=data source=127.0.0.1,1433;Initial Catalog=db;Integrated Security=True;
    ports:
      - "11102:80"

我收到此错误

: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)'

这里有什么问题? 顺便说一句,我可以在本地连接到127.0.0.1,1433。

1 个答案:

答案 0 :(得分:3)

容器内的地址127.0.0.1引用容器本身。使用主机的另一个IP地址连接到它。