我正在尝试创建docker-compose文件来为我的ASP.NET Core应用协调多个容器。但是,由于出现错误“建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问该服务器”,我无法连接到SQL Linux服务器。错误代码为139-数据库连接出现问题。
docker-compose.yml
version: '3.5'
services:
tag1:
image: repousername/reponame:tag1
environment:
- ASPNETCORE_ENVIRONMENT=Docker
deploy:
replicas: 1
resources:
limits:
cpus: "0.3"
memory: 500M
restart_policy:
condition: on-failure
ports:
- "44444"
depends_on:
- db
tag2:
image: repousername/reponame:tag2
environment:
- ASPNETCORE_ENVIRONMENT=Docker
deploy:
replicas: 1
resources:
limits:
cpus: "0.3"
memory: 500M
restart_policy:
condition: on-failure
ports:
- "55555"
depends_on:
- db
- tag1
db:
image: "mcr.microsoft.com/mssql/server"
environment:
SA_PASSWORD: "<strong_password>"
ACCEPT_EULA: "Y"
这是我用来连接数据库的连接字符串:
Server=db; Initial Catalog = somecatalog;User Id=SA; Password=<strong_password>; MultipleActiveResultSets=True
请问问题是否与连接字符串或docker-compose.yml文件有关?