gpt4 book ai didi

azure - 无法连接到 Azure Pipelines 中的 docker

转载 作者:行者123 更新时间:2023-12-03 03:38:03 24 4
gpt4 key购买 nike

在我的 Azure Pipeline 中,我使用以下命令使用 docker run 创建了一个容器:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Pa$$w0rd12' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu

在另一项任务中,我尝试使用 docker ps 列出此容器,它向我显示了如下容器:

/usr/bin/docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afca60eb6fde mcr.microsoft.com/mssql/server:2017-latest-ubuntu "/opt/mssql/bin/nonr…" 1 second ago Up Less than a second 0.0.0.0:1433->1433/tcp, :::1433->1433/tcp nostalgic_jemison
Finishing: list docker containers

发布我正在尝试运行我的 dotnet 集成测试,该测试使用上述 SQL 服务器容器。这些测试应该在服务器内创建自己的数据库,运行测试并删除它们。但在运行测试时失败并出现以下错误:

  Error Message:
System.AggregateException : One or more errors occurred. (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: 40 - Could not open a connection to SQL Server)) (The following constructor parameters did not have matching fixture data: DatabaseSetup databaseSetup)
---- Microsoft.Data.SqlClient.SqlException : 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: 40 - Could not open a connection to SQL Server)
---- The following constructor parameters did not have matching fixture data: DatabaseSetup databaseSetup

我在集成测试中使用的连接字符串如下:

“数据源=localhost,1433;初始目录=dbname;用户ID=SA;密码=Pa$$w0rd12”

我使用 Ubuntu 20.04 作为构建代理。相同的设置在使用 Ubuntu20.04 的 WSL 本地系统上运行良好

更新 1:我已将连接字符串中的 localhost 替换为容器的 IP 地址。在本地 WSL 中工作正常,但在 Azure Pipelines 上仍然引发相同的错误。

更新 2:我刚刚注意到,当我在管道中运行 dotnet test 时,容器停止了。我可以在 dotnet 测试之前看到容器正在运行,但在 dotnet 测试之后看不到容器处于事件状态

最佳答案

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: 40 - Could not open a connection to SQL Server)

您可以按照以下步骤排查错误:

  1. Verify that the instance is running

  2. Verify that the SQL Server Browser service is running

  3. Verify the server name in the connection string

  4. Verify the aliases on the client machines

  5. Verify the firewall configuration

  6. Verify the enabled protocols on SQL Server

  7. Test TCP/IP connectivity

  8. 测试本地连接

  9. 测试远程连接

The following constructor parameters did not have matching fixture

data: DatabaseSetup databaseSetup

您可以引用The following constructor parameters did not have matching fixture data以获得更多帮助。

关于azure - 无法连接到 Azure Pipelines 中的 docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72615254/

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