[英]MSDTC configuration issues with SQL Server in Docker (Linux) and Windows Host
I'm migrating a local SQL Server development database to run in a Linux docker container (on the same dev machine).我正在迁移本地 SQL Server 开发数据库以在 Linux docker 容器(在同一台开发机器上)中运行。 When running my integration tests in Visual Studio 2019 on Windows, I receive MSDTC errors:
在 Windows 上的 Visual Studio 2019 中运行我的集成测试时,我收到 MSDTC 错误:
Exception thrown: 'System.Transactions.TransactionManagerCommunicationException' in System.Data.dll An exception of type 'System.Transactions.TransactionManagerCommunicationException' occurred in System.Data.dll but was not handled in user code Communication with the underlying transaction manager has failed.
抛出异常:System.Data.dll 中的“System.Transactions.TransactionManagerCommunicationException” System.Data.dll 中发生类型为“System.Transactions.TransactionManagerCommunicationException”的异常,但未在用户代码中处理 与底层事务管理器的通信失败。
Here's my latest iteration of SQL Server in my docker-compose:这是我在 docker-compose 中最新的 SQL Server 迭代:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
container_name: SqlServer
restart: always
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=verySecretPassword
- MSSQL_RPC_PORT=13500
- MSSQL_DTC_TCP_PORT=51000
ports:
- "1401:1433"
- "135:13500"
- "51000:51000"
volumes:
- sqldata:/var/opt/mssql
I've tried all sorts of ways to adjust the RPC port to get this working.我尝试了各种方法来调整 RPC 端口以使其正常工作。 This is the main MS article .
这是主要的 MS 文章。 I've tried port
135:135
but it gives the same error.我试过端口
135:135
但它给出了同样的错误。 The note in the article at the bottom appears to be related to my issue.底部文章中的注释似乎与我的问题有关。
For SQL Server outside of a container or for non-root containers, a different ephemeral port, such as 13500, must be used in the container and traffic to port 135 must then be routed to that port.
对于容器外部的 SQL Server 或非根容器,必须在容器中使用不同的临时端口,例如 13500,然后必须将到端口 135 的流量路由到该端口。 You would also need to configure port routing rules within the container from the container port 135 to the ephemeral port.
您还需要在容器内配置从容器端口 135 到临时端口的端口路由规则。
Also, if you decide to map the container's port 135 to a different port on the host, such as 13500, then you have to configure port routing on the host.
此外,如果您决定将容器的端口 135 映射到主机上的其他端口,例如 13500,则必须在主机上配置端口路由。 This enables the docker container to participate in distributed transactions with the host and with other external servers.
这使 docker 容器能够参与与主机和其他外部服务器的分布式事务。
SQL Server 2019 containers run as a non-root user. SQL Server 2019 容器以非 root 用户身份运行。 I've tried port routing using netsh in windows... and also the MS article links to how to perform port forwarding in Ubuntu... which I'm unable to do even when logged in as root in the SQL Server container... iptables is not installed, and it doesn't let me
apt-get install
it??我已经尝试过在 Windows 中使用 netsh 进行端口路由......还有 MS 文章链接到如何在 Ubuntu 中执行端口转发......即使在 SQL Server 容器中以 root 身份登录时我也无法做到...... .iptables 没有安装,也不让我
apt-get install
?? I also updated the DTC options in windows to make it as open as possible, but it had no effect.我还更新了 Windows 中的 DTC 选项,使其尽可能打开,但没有任何效果。 Not sure what the secret sauce is.
不知道秘方是什么。 Hoping someone else has a similar setup that works.
希望其他人有类似的设置。
Thanks for the tip on msdtc
config, I got mine working with this compose:感谢有关
msdtc
配置的提示,我开始使用此组合:
version: '3.4'
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
container_name: sqlserver
user: root
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=[yourPwd]
- MSSQL_RPC_PORT=135
- MSSQL_DTC_TCP_PORT=51000
ports:
- "1433:1433"
- "135:135"
- "51000:51000"
volumes:
- D:\DockerVolumes\sqlserver:/var/opt/mssql/data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.