SQL Docker 的 Server 2017 无法运行(因为缺少 ipv6?)
SQL Server 2017 for Docker does not work (because of missing ipv6?)
我正在开发 SQL Server 2017 Docker 容器。数据库永远不会启动。
我只为运行健康检查定制了图片。不使用自定义的 Docker 文件也会出现同样的问题。
主机已完全禁用 ipv6。 Docker 的 daemon.json
有 属性 "ipv6" : false
.
Docker文件(过时)
FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
ENV ACCEPT_EULA=Y
EXPOSE 1433
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=10 \
CMD /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q "SELECT 1" || exit 1
日志
2019-12-03 15:10:44.73 spid19s SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the operating system error log for information about possible related problems.
2019-12-03 15:10:44.71 spid19s Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742. To proceed, notify your system administrator.
2019-12-03 15:10:44.71 spid19s TDSSNIClient initialization failed with error 0x2742, status code 0xa. Reason: Unable to initialize the TCP/IP listener. A socket operation encountered a dead network.
2019-12-03 15:10:44.72 spid19s TDSSNIClient initialization failed with error 0x2742, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. A socket operation encountered a dead network.
2019-12-03 15:10:44.71 spid19s Error: 26024, Severity: 16, State: 1.
2019-12-03 15:10:44.71 spid19s Error: 17182, Severity: 16, State: 1.
2019-12-03 15:10:44.72 spid19s Error: 17182, Severity: 16, State: 1.
2019-12-03 15:10:44.72 spid19s Error: 17826, Severity: 18, State: 3.
2019-12-03 15:10:44.72 spid19s Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2019-12-03 15:10:44.73 spid19s Error: 17120, Severity: 16, State: 1.
我曾尝试 运行 sysctl
直接在容器上显式禁用 ipv6,但似乎不需要。
$ sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl: cannot stat /proc/sys/net/ipv6/conf/all/disable_ipv6: No such file or directory
问题:我该如何解决这个问题?问题真的与 ipv6 disconnectivity 有关吗?
有什么方法可以告诉 mssql
不要尝试使用 ipv6?
更新
我试过以下Docker文件
FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
ENV MSSQL_IP_ADDRESS=0.0.0.0
ENV ACCEPT_EULA=Y
ENV MSSQL_PID=Express
RUN MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
EXPOSE 1433
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=10 \
CMD /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q "SELECT 1" || exit 1
错误是
Building image...
Preparing build context archive...
[==================================================>]2/2 files
Done
Sending build context to Docker daemon...
[==================================================>] 566,0B
Done
Step 1/7 : FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
---> cfe5615bf6a8
Step 2/7 : ENV MSSQL_IP_ADDRESS=0.0.0.0
---> Running in d65d0c977ea1
Removing intermediate container d65d0c977ea1
---> 358ed84b0ae7
Step 3/7 : ENV ACCEPT_EULA=Y
---> Running in b0a6b46edb0a
Removing intermediate container b0a6b46edb0a
---> ed69c043b383
Step 4/7 : ENV MSSQL_PID=Express
---> Running in e58a9930791c
Removing intermediate container e58a9930791c
---> 94f055e34ba0
Step 5/7 : RUN MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
---> Running in 508cacc5158a
Traceback (most recent call last):
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 279, in <module>
main()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 275, in main
processCommands()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 199, in processCommands
COMMAND_TABLE[args.which]()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 54, in handleSetup
exit(mssqlconfhelper.setupSqlServer(eulaAccepted, noprompt=args.noprompt))
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 795, in setupSqlServer
if not checkInstall():
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 765, in checkInstall
return runScript(checkInstallScript, True) == 0
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 754, in runScript
return subprocess.call([sudo, "-EH", pathToScript])
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Error response from daemon: The command '/bin/sh -c MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup' returned a non-zero code: 1
这似乎是一个记录在案的问题,您可以通过搜索错误找到它:
Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742
这会引导您找到描述问题的文档:Mssql-conf tool fails if IPV6 is disabled on the Linux system:
Symptoms
Assume that you try to install Microsoft SQL Server 2017 on a Linux
operating system such as Redhat or Ubuntu. If IPv6 is disabled at the
OS kernel level, and you try to configure SQL Server by using the
"sudo /opt/mssql/bin/mssql-conf setup" command, you receive the
following messages in the Linux console and SQL Server error log.
Additionally, the configuration may fail.
并且我们可以在上述错误日志中看到您描述的错误:
SQL Server error log:
...
DateTimeAndSpid Error: 26024, Severity: 16, State: 1.
DateTimeAndSpid Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742. To proceed, notify your system administrator.
DateTimeAndSpid Error: 17182, Severity: 16, State: 1.
DateTimeAndSpid TDSSNIClient initialization failed with error 0x2742, status code 0xa. Reason: Unable to initialize the TCP/IP listener. A socket operation encountered a dead network.
DateTimeAndSpid Error: 17182, Severity: 16, State: 1.
DateTimeAndSpid TDSSNIClient initialization failed with error 0x2742, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. A socket operation encountered a dead network.
...
并提供解决方法:
Workaround
To work around the issue, run the following command:
sudo MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
目前,除了指定上述解决方法(这可能是由于 "design")之外,Microsoft 似乎并未致力于 "avoid" 错误:
Status
Microsoft has confirmed that this is a problem in the Microsoft
products that are listed in the "Applies to" section.
我正在开发 SQL Server 2017 Docker 容器。数据库永远不会启动。
我只为运行健康检查定制了图片。不使用自定义的 Docker 文件也会出现同样的问题。
主机已完全禁用 ipv6。 Docker 的 daemon.json
有 属性 "ipv6" : false
.
Docker文件(过时)
FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
ENV ACCEPT_EULA=Y
EXPOSE 1433
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=10 \
CMD /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q "SELECT 1" || exit 1
日志
2019-12-03 15:10:44.73 spid19s SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the operating system error log for information about possible related problems.
2019-12-03 15:10:44.71 spid19s Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742. To proceed, notify your system administrator.
2019-12-03 15:10:44.71 spid19s TDSSNIClient initialization failed with error 0x2742, status code 0xa. Reason: Unable to initialize the TCP/IP listener. A socket operation encountered a dead network.
2019-12-03 15:10:44.72 spid19s TDSSNIClient initialization failed with error 0x2742, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. A socket operation encountered a dead network.
2019-12-03 15:10:44.71 spid19s Error: 26024, Severity: 16, State: 1.
2019-12-03 15:10:44.71 spid19s Error: 17182, Severity: 16, State: 1.
2019-12-03 15:10:44.72 spid19s Error: 17182, Severity: 16, State: 1.
2019-12-03 15:10:44.72 spid19s Error: 17826, Severity: 18, State: 3.
2019-12-03 15:10:44.72 spid19s Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2019-12-03 15:10:44.73 spid19s Error: 17120, Severity: 16, State: 1.
我曾尝试 运行 sysctl
直接在容器上显式禁用 ipv6,但似乎不需要。
$ sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl: cannot stat /proc/sys/net/ipv6/conf/all/disable_ipv6: No such file or directory
问题:我该如何解决这个问题?问题真的与 ipv6 disconnectivity 有关吗?
有什么方法可以告诉 mssql
不要尝试使用 ipv6?
更新
我试过以下Docker文件
FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
ENV MSSQL_IP_ADDRESS=0.0.0.0
ENV ACCEPT_EULA=Y
ENV MSSQL_PID=Express
RUN MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
EXPOSE 1433
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=10 \
CMD /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q "SELECT 1" || exit 1
错误是
Building image...
Preparing build context archive...
[==================================================>]2/2 files
Done
Sending build context to Docker daemon...
[==================================================>] 566,0B
Done
Step 1/7 : FROM mcr.microsoft.com/mssql/server:2017-latest-ubuntu
---> cfe5615bf6a8
Step 2/7 : ENV MSSQL_IP_ADDRESS=0.0.0.0
---> Running in d65d0c977ea1
Removing intermediate container d65d0c977ea1
---> 358ed84b0ae7
Step 3/7 : ENV ACCEPT_EULA=Y
---> Running in b0a6b46edb0a
Removing intermediate container b0a6b46edb0a
---> ed69c043b383
Step 4/7 : ENV MSSQL_PID=Express
---> Running in e58a9930791c
Removing intermediate container e58a9930791c
---> 94f055e34ba0
Step 5/7 : RUN MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
---> Running in 508cacc5158a
Traceback (most recent call last):
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 279, in <module>
main()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 275, in main
processCommands()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 199, in processCommands
COMMAND_TABLE[args.which]()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 54, in handleSetup
exit(mssqlconfhelper.setupSqlServer(eulaAccepted, noprompt=args.noprompt))
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 795, in setupSqlServer
if not checkInstall():
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 765, in checkInstall
return runScript(checkInstallScript, True) == 0
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 754, in runScript
return subprocess.call([sudo, "-EH", pathToScript])
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Error response from daemon: The command '/bin/sh -c MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup' returned a non-zero code: 1
这似乎是一个记录在案的问题,您可以通过搜索错误找到它:
Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742
这会引导您找到描述问题的文档:Mssql-conf tool fails if IPV6 is disabled on the Linux system:
Symptoms
Assume that you try to install Microsoft SQL Server 2017 on a Linux operating system such as Redhat or Ubuntu. If IPv6 is disabled at the OS kernel level, and you try to configure SQL Server by using the "sudo /opt/mssql/bin/mssql-conf setup" command, you receive the following messages in the Linux console and SQL Server error log. Additionally, the configuration may fail.
并且我们可以在上述错误日志中看到您描述的错误:
SQL Server error log:
... DateTimeAndSpid Error: 26024, Severity: 16, State: 1. DateTimeAndSpid Server failed to listen on 'any' <ipv6> 1433. Error: 0x2742. To proceed, notify your system administrator. DateTimeAndSpid Error: 17182, Severity: 16, State: 1. DateTimeAndSpid TDSSNIClient initialization failed with error 0x2742, status code 0xa. Reason: Unable to initialize the TCP/IP listener. A socket operation encountered a dead network. DateTimeAndSpid Error: 17182, Severity: 16, State: 1. DateTimeAndSpid TDSSNIClient initialization failed with error 0x2742, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. A socket operation encountered a dead network. ...
并提供解决方法:
Workaround
To work around the issue, run the following command:
sudo MSSQL_IP_ADDRESS=0.0.0.0 /opt/mssql/bin/mssql-conf setup
目前,除了指定上述解决方法(这可能是由于 "design")之外,Microsoft 似乎并未致力于 "avoid" 错误:
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.