gpt4 book ai didi

sql-server - Docker SQL Server异常

转载 作者:行者123 更新时间:2023-12-02 19:47:52 25 4
gpt4 key购买 nike

在Docker容器中运行.NET Core 3.1 Web API项目时遇到SQL异常

Microsoft.Data.SqlClient.SqlException (0x80131904): 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 connection



version: "3.7"

services:

SQLServer:
image: mcr.microsoft.com/mssql/server
container_name: SQLServer
networks:
mynetwork:
aliases:
- db1.internal.prod.example.com

CRUD_JSON_API:
image: koccan9/crud_json_api:samplev3
container_name: "crud_json_api_sample"
restart: on-failure
build:
context: .
dockerfile: CRUD_JSON_API/Dockerfile
depends_on:
- SQLServer
networks:
mynetwork:
aliases:
- web1.internal.prod.example.com

volumes:
mssql-server-julie-data: {}

networks:
mynetwork:
driver: bridge




version: '3.7'

services:

SQLServer:
environment:
- MSSQL_SA_PASSWORD=xxx
- ACCEPT_EULA=Y
- MSSQL_PID=Developer
ports:
- "1433:1433"
volumes:
- ./data/mssql:/var/opt/mssql3
expose:
- 1433

CRUD_JSON_API:
links:
- SQLServer
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionString=${IDENTITY_DB:-Server=SQLServer;Database=DEV_CRUD_JSON_API;User Id=sa;Password=xxx}
ports:
- "5000:80"

最佳答案

确保In SQL Server配置正确。此外,请检查以下链接:mssql-docker-issues

关于sql-server - Docker SQL Server异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62614394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com