I am trying to use Docker Compose to set up MSDTC in a SQL Server container as described here:
My compose file looks like this, mirroring the command-line arguments referenced in the above document:
services:
pte_mssql:
build:
context: ./mssql/docker
environment:
ACCEPT_EULA: 'Y'
MSSQL_SA_PASSWORD: '${startupSaPassword}'
MSSQL_RPC_PORT: 135
MSSQL_DTC_TCP_PORT: 51000
ports:
- 1433:1433
- 135:135
- 51000:51000
However, the DTC service does not appear to start. I see this repeated in the output (other ports seem to be OK):
Waiting for TCP socket on 172.24.0.1:51000 of 'pte_mssql_1' (Connection refused (Connection refused))
Will use 172.24.0.1 (network vestmarkone_default) as host of pte_mssql
More forwarded TCP ports for service 'pte_mssql:135 [[HostIp:0.0.0.0, HostPort:135], [HostIp:::, HostPort:135]]'. Will use the first one.
More forwarded TCP ports for service 'pte_mssql:1433 [[HostIp:0.0.0.0, HostPort:1433], [HostIp:::, HostPort:1433]]'. Will use the first one.
More forwarded TCP ports for service 'pte_mssql:51000 [[HostIp:0.0.0.0, HostPort:51000], [HostIp:::, HostPort:51000]]'. Will use the first one.
I used the following command to confirm that nothing is running on port 51000:
root@906e7184f6bc:/var/opt/mssql/log# lsof -i -P -n | grep LISTEN
sqlservr 9 root 49u IPv4 1613252 0t0 TCP *:135 (LISTEN)
sqlservr 9 root 51u IPv6 1613254 0t0 TCP *:135 (LISTEN)
sqlservr 9 root 64u IPv6 1617097 0t0 TCP *:1433 (LISTEN)
sqlservr 9 root 100u IPv4 1617098 0t0 TCP *:1433 (LISTEN)
sqlservr 9 root 106u IPv4 1629465 0t0 TCP 127.0.0.1:1434 (LISTEN)
sqlservr 9 root 110u IPv4 1617101 0t0 TCP 127.0.0.1:1431 (LISTEN)
I also tried adding the following to my Dockerfile
instead of setting the MSSQL_DTC_TCP_PORT
environment variable:
RUN /opt/mssql/bin/mssql-conf set distributedtransaction.servertcpport 51000
This did not resolve the problem.
FWIW, creating the container from the command line (as shown in the article) rather than via Docker Compose produces the same results. Note that I started the container as root so I could run lsof
to troubleshoot. I also used "2019-latest" rather than "2019-GA-ubuntu-20.04" since the latter no longer appears to exist:
docker run \
-u root \
-e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=pass@1234' \
-e 'MSSQL_RPC_PORT=135' -e 'MSSQL_DTC_TCP_PORT=51000' \
-p 1433:1433 -p 135:135 -p 51000:51000 \
-d mcr.microsoft.com/mssql/server:2019-latest
Does anyone have any suggestions for how to enable the DTC service, or how to troubleshoot further?
According to Microsoft's documentation, the DTC server will not start listening until a distributed transaction has begun. Once that occurs, you should see it listening on port 51000.