1

运行容器

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Password_01!" -p 1433:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest

容器状态为UP

试图连接

docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password_01!

或使用 localhost 的 docker machine ip insted

docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S 192.168.99.100 -U SA -P 'Password_01!'

我收到了这个错误:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Timeout error [258]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Unable to complete login process due to delay in prelogin response.

这是容器日志

$ docker logs sql1
2018-08-17 12:41:55.65 Server      Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2018-08-17 12:41:55.77 Server      Did not find an existing master data file /var/opt/mssql/data/master.mdf, copying the missing default master and other system database files. If you have moved the database location, but not moved the database files, startup may fail. To repair: shutdown SQL Server, move the master database to configured location, and restart.
2018-08-17 12:41:55.78 Server      Setup step is copying system data file 'C:\templatedata\mastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2018-08-17 12:41:55.81 Server      Setup step is copying system data file 'C:\templatedata\model.mdf' to '/var/opt/mssql/data/model.mdf'.
2018-08-17 12:41:55.91 Server      Setup step is copying system data file 'C:\templatedata\modellog.ldf' to '/var/opt/mssql/data/modellog.ldf'.
2018-08-17 12:41:56.01 Server      Setup step is copying system data file 'C:\templatedata\msdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'.
2018-08-17 12:41:56.17 Server      Setup step is copying system data file 'C:\templatedata\msdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2018-08-17 12:41:56.26 Server      Microsoft SQL Server 2017 (RTM-CU9-GDR) (KB4293805) - 14.0.3035.2 (X64)
        Jul  6 2018 18:24:36
        Copyright (C) 2017 Microsoft Corporation
        Developer Edition (64-bit) on Linux (Ubuntu 16.04.5 LTS)
2018-08-17 12:41:56.27 Server      UTC adjustment: 0:00
2018-08-17 12:41:56.27 Server      (c) Microsoft Corporation.
2018-08-17 12:41:56.27 Server      All rights reserved.
2018-08-17 12:41:56.27 Server      Server process ID is 4120.
2018-08-17 12:41:56.27 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2018-08-17 12:41:56.27 Server      Registry startup parameters:
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2018-08-17 12:41:56.28 Server      SQL Server detected 1 sockets with 1 cores per socket and 1 logical processors per socket, 1 total logical processors; using 1 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2018-08-17 12:41:56.29 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2018-08-17 12:41:56.29 Server      Detected 3160 MB of RAM. This is an informational message; no user action is required.
2018-08-17 12:41:56.30 Server      Using conventional memory in the memory manager.
2018-08-17 12:41:56.70 Server      Buffer pool extension is already disabled. No action is necessary.
2018-08-17 12:41:57.35 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2018-08-17 12:41:57.35 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2018-08-17 12:41:57.35 Server      Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
2018-08-17 12:41:57.59 Server      The maximum number of dedicated administrator connections for this instance is '1'
2018-08-17 12:41:57.59 Server      Node configuration: node 0: CPU mask: 0x0000000000000001:0 Active CPU mask: 0x0000000000000001:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2018-08-17 12:41:57.72 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2018-08-17 12:41:57.80 Server      In-Memory OLTP initialized on lowend machine.
2018-08-17 12:41:58.09 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
ForceFlush is enabled for this instance.
2018-08-17 12:41:58.13 Server      Query Store settings initialized with enabled = 1,
2018-08-17 12:41:58.33 spid6s      Starting up database 'master'.
2018-08-17 12:41:58.39 Server      Software Usage Metrics is disabled.
ForceFlush feature is enabled for log durability.
2018-08-17 12:41:58.95 spid6s      The tail of the log for database master is being rewritten to match the new sector size of 4096 bytes.  3072 bytes at offset 418816 in file /var/opt/mssql/data/mastlog.ldf will be written.
2018-08-17 12:42:00.16 spid6s      Converting database 'master' from version 862 to the current version 869.
2018-08-17 12:42:00.16 spid6s      Database 'master' running the upgrade step from version 862 to version 863.
2018-08-17 12:42:00.62 spid6s      Database 'master' running the upgrade step from version 863 to version 864.
2018-08-17 12:42:01.38 spid6s      Database 'master' running the upgrade step from version 864 to version 865.
2018-08-17 12:42:01.76 spid6s      Database 'master' running the upgrade step from version 865 to version 866.
2018-08-17 12:42:02.12 spid6s      Database 'master' running the upgrade step from version 866 to version 867.
2018-08-17 12:42:02.56 spid6s      Database 'master' running the upgrade step from version 867 to version 868.
2018-08-17 12:42:02.97 spid6s      Database 'master' running the upgrade step from version 868 to version 869.
2018-08-17 12:42:05.05 spid6s      Resource governor reconfiguration succeeded.
2018-08-17 12:42:05.06 spid6s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2018-08-17 12:42:05.07 spid6s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2018-08-17 12:42:05.36 spid6s      SQL Trace ID 1 was started by login "sa".
2018-08-17 12:42:05.77 spid20s     Password policy update was successful.
2018-08-17 12:42:06.15 spid6s      Server name is '980bd8d92bc7'. This is an informational message only. No user action is required.
2018-08-17 12:42:06.35 spid23s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2018-08-17 12:42:06.36 spid6s      Starting up database 'msdb'.
2018-08-17 12:42:06.36 spid23s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2018-08-17 12:42:06.37 spid9s      Starting up database 'mssqlsystemresource'.
2018-08-17 12:42:06.37 spid9s      The resource database build version is 14.00.3035. This is an informational message only. No user action is required.
2018-08-17 12:42:06.51 spid9s      Starting up database 'model'.
2018-08-17 12:42:06.89 spid6s      The tail of the log for database msdb is being rewritten to match the new sector size of 4096 bytes.  512 bytes at offset 306688 in file /var/opt/mssql/data/MSDBLog.ldf will be written.
2018-08-17 12:42:06.95 spid20s     A self-generated certificate was successfully loaded for encryption.
2018-08-17 12:42:07.08 spid20s     Server is listening on [ 'any' <ipv4> 1433].
2018-08-17 12:42:07.09 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
2018-08-17 12:42:07.09 Server      Dedicated admin connection support was established for listening locally on port 1434.
2018-08-17 12:42:07.16 spid20s     SQL Server is now ready for client connections. This is an informational message; no user action is required.

这是我遵循的参考:https ://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017

4

1 回答 1

0

我发现给容器一个主机名(-h 选项),然后连接到该主机名,如果这是你的一个选项,我发现了更多的成功。

于 2018-08-17T13:49:17.033 回答