want to use the mssql to test in pipeline, following the document to build the service, but I always get an error, cannot connect to the service.
I am not sure which part be wrong, could you help me to point out?
error message
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AFA.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online…
/opt/mssql-tools/bin/sqlcmd -S database,1433 -U sa -P ${{DB_PWD}} -i ./init.sql
${{DB_PWD}} should be $${DB_PWD}
Could you also try playing around a bit with sleep, and see if increasing it a bit fixes it? I’m not sure how long it takes to start, but it might be worth running both commands a few times, just for debugging purposes:
Looking at the docs to see if something was forgotten for SQL Server - could you try specifying the product ID like so?
environment:
ACCEPT_EULA: Y
SA_PASSWORD: $${DB_PWD}
MSSQL_PID: Express
I don’t think you should have to publish the port, as them being reachable by container name makes me think they’re on the same Docker network (and thus wouldn’t need a port published to the host machine).
Could you check the logs of the SQL container while your pipeline is running? I remember having some permission issues when running the container for some programs I run.
Just run sleep 5000 or something similar in your pipeline so the pipeline doesn’t complete while you’re checking the logs (you can just kill the build after).
The SQL container is living when the initialize step is running, and there have no permission issue.
run sleep 5000, like this picture
log here
SQL Server 2019 will run as non-root by default.
This container is running as user root.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2021-06-10 09:46:56.99 Server The licensing PID was successfully processed. The new edition is [Express Edition].
2021-06-10 09:46:57.55 Server Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2021-06-10 09:46:57.57 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.
2021-06-10 09:46:57.59 Server Setup step is copying system data file 'C:\templatedata\mastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2021-06-10 09:46:57.61 Server Setup step is copying system data file 'C:\templatedata\model.mdf' to '/var/opt/mssql/data/model.mdf'.
2021-06-10 09:46:57.62 Server Setup step is copying system data file 'C:\templatedata\modellog.ldf' to '/var/opt/mssql/data/modellog.ldf'.
2021-06-10 09:46:57.64 Server Setup step is copying system data file 'C:\templatedata\msdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'.
2021-06-10 09:46:57.66 Server Setup step is copying system data file 'C:\templatedata\msdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2021-06-10 09:46:57.74 Server Microsoft SQL Server 2017 (RTM-CU24) (KB5001228) - 14.0.3391.2 (X64)
Apr 28 2021 10:32:18
Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Linux (Ubuntu 16.04.7 LTS)
2021-06-10 09:46:57.75 Server UTC adjustment: 0:00
2021-06-10 09:46:57.76 Server (c) Microsoft Corporation.
2021-06-10 09:46:57.76 Server All rights reserved.
2021-06-10 09:46:57.76 Server Server process ID is 396.
2021-06-10 09:46:57.77 Server Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2021-06-10 09:46:57.77 Server Registry startup parameters:
-d /var/opt/mssql/data/master.mdf
-l /var/opt/mssql/data/mastlog.ldf
-e /var/opt/mssql/log/errorlog
2021-06-10 09:46:57.79 Server SQL Server detected 1 sockets with 6 cores per socket and 6 logical processors per socket, 6 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2021-06-10 09:46:57.80 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2021-06-10 09:46:57.81 Server Detected 10142 MB of RAM. This is an informational message; no user action is required.
2021-06-10 09:46:57.82 Server Using conventional memory in the memory manager.
2021-06-10 09:46:57.82 Server Page exclusion bitmap is enabled.
2021-06-10 09:46:58.03 Server Buffer pool extension is already disabled. No action is necessary.
2021-06-10 09:46:58.61 Server InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2021-06-10 09:46:58.62 Server Implied authentication manager initialization failed. Implied authentication will be disabled.
2021-06-10 09:46:58.63 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'].
2021-06-10 09:46:58.70 Server Query Store settings initialized with enabled = 1,
2021-06-10 09:46:58.74 Server Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2021-06-10 09:46:58.74 Server The maximum number of dedicated administrator connections for this instance is '1'
2021-06-10 09:46:58.78 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.
2021-06-10 09:46:58.80 Server In-Memory OLTP initialized on lowend machine.
2021-06-10 09:46:58.84 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.
2021-06-10 09:46:58.88 Server Software Usage Metrics is disabled.
2021-06-10 09:46:58.89 spid6s Starting up database 'master'.
ForceFlush feature is enabled for log durability.
2021-06-10 09:46:58.96 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.
2021-06-10 09:46:59.20 spid6s Converting database 'master' from version 862 to the current version 869.
2021-06-10 09:46:59.20 spid6s Database 'master' running the upgrade step from version 862 to version 863.
2021-06-10 09:46:59.26 spid6s Database 'master' running the upgrade step from version 863 to version 864.
2021-06-10 09:46:59.31 spid6s Database 'master' running the upgrade step from version 864 to version 865.
2021-06-10 09:46:59.35 spid6s Database 'master' running the upgrade step from version 865 to version 866.
2021-06-10 09:46:59.38 spid6s Database 'master' running the upgrade step from version 866 to version 867.
2021-06-10 09:46:59.41 spid6s Database 'master' running the upgrade step from version 867 to version 868.
2021-06-10 09:46:59.44 spid6s Database 'master' running the upgrade step from version 868 to version 869.
2021-06-10 09:46:59.78 spid6s SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2021-06-10 09:46:59.79 spid6s SQL Server Audit has started the audits. This is an informational message. No user action is required.
2021-06-10 09:46:59.84 spid6s SQL Trace ID 1 was started by login "sa".
2021-06-10 09:46:59.87 spid18s Password policy update was successful.
2021-06-10 09:46:59.88 spid6s Server name is '29fffdce2b9e'. This is an informational message only. No user action is required.
2021-06-10 09:46:59.92 spid19s Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2021-06-10 09:46:59.93 spid11s Starting up database 'mssqlsystemresource'.
2021-06-10 09:46:59.93 spid6s Starting up database 'msdb'.
2021-06-10 09:46:59.94 spid19s 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.
2021-06-10 09:46:59.95 spid11s The resource database build version is 14.00.3391. This is an informational message only. No user action is required.
2021-06-10 09:47:00.01 spid11s Starting up database 'model'.
2021-06-10 09:47:00.03 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.
2021-06-10 09:47:00.08 spid11s The tail of the log for database model is being rewritten to match the new sector size of 4096 bytes. 2048 bytes at offset 75776 in file /var/opt/mssql/data/modellog.ldf will be written.
2021-06-10 09:47:00.10 spid18s A self-generated certificate was successfully loaded for encryption.
2021-06-10 09:47:00.12 spid18s Server is listening on [ 'any' <ipv6> 1433].
2021-06-10 09:47:00.13 spid18s Server is listening on [ 'any' <ipv4> 1433].
2021-06-10 09:47:00.16 spid18s Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2021-06-10 09:47:00.16 spid6s Converting database 'msdb' from version 862 to the current version 869.
2021-06-10 09:47:00.20 spid18s SQL Server is now ready for client connections. This is an informational message; no user action is required.
2021-06-10 09:47:00.21 spid6s Database 'msdb' running the upgrade step from version 862 to version 863.
2021-06-10 09:47:00.31 spid11s Converting database 'model' from version 862 to the current version 869.
2021-06-10 09:47:00.33 spid11s Database 'model' running the upgrade step from version 862 to version 863.
2021-06-10 09:47:00.43 spid6s Database 'msdb' running the upgrade step from version 863 to version 864.
2021-06-10 09:47:00.45 spid11s Database 'model' running the upgrade step from version 863 to version 864.
2021-06-10 09:47:00.47 spid6s Database 'msdb' running the upgrade step from version 864 to version 865.
2021-06-10 09:47:00.51 spid11s Database 'model' running the upgrade step from version 864 to version 865.
2021-06-10 09:47:00.51 spid6s Database 'msdb' running the upgrade step from version 865 to version 866.
2021-06-10 09:47:00.54 spid11s Database 'model' running the upgrade step from version 865 to version 866.
2021-06-10 09:47:00.55 spid6s Database 'msdb' running the upgrade step from version 866 to version 867.
2021-06-10 09:47:00.58 spid11s Database 'model' running the upgrade step from version 866 to version 867.
2021-06-10 09:47:00.59 spid6s Database 'msdb' running the upgrade step from version 867 to version 868.
2021-06-10 09:47:00.61 spid11s Database 'model' running the upgrade step from version 867 to version 868.
2021-06-10 09:47:00.61 spid6s Database 'msdb' running the upgrade step from version 868 to version 869.
2021-06-10 09:47:00.65 spid11s Database 'model' running the upgrade step from version 868 to version 869.
2021-06-10 09:47:00.81 spid11s Polybase feature disabled.
2021-06-10 09:47:00.81 spid11s Clearing tempdb database.
2021-06-10 09:47:00.84 spid19s ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols..
2021-06-10 09:47:00.87 spid19s An error occurred during server setup. See previous errors for more information.
2021-06-10 09:47:00.87 spid19s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols…