The run command:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=password' -p 1433:1433 --name sql -d microsoft/mssql-server-linux:2017-latest
OS:
macOS High Sierra 10.13.5 (17F77)
Docker:
Community Edition 18.03.1-ce-mac65 (24312)
Image:
microsoft/mssql-server-linux 2017-latest
Log:
2018-07-02 20:39:49.45 Server Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2018-07-02 20:39:49.50 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-07-02 20:39:49.51 Server Setup step is copying system data file 'C:\templatedata\mastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2018-07-02 20:39:49.51 Server Setup step is copying system data file 'C:\templatedata\model.mdf' to '/var/opt/mssql/data/model.mdf'.
2018-07-02 20:39:49.52 Server Setup step is copying system data file 'C:\templatedata\modellog.ldf' to '/var/opt/mssql/data/modellog.ldf'.
2018-07-02 20:39:49.53 Server Setup step is copying system data file 'C:\templatedata\msdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'.
Just checking - did you use a sufficiently complex password or literally 'password'?
Just literally „password“
OK yeah, the password needs to meet complexity requirements.
https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-2017
I cant get this dockerfile to work properly. The SQL service will not start Docker logs show:
docker logs 403
VERBOSE: Starting SQL Server
VERBOSE: Changing SA login credentials
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
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..
VERBOSE: Started SQL Server.
PS E:\spikecontainerstaging\sqlservercontainerv2> docker exec -it 403 powershell.exe
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:> get-service SQL
Status Name DisplayName
------ ---- -----------
Stopped MSSQL$SQLEXPRESS SQL Server (SQLEXPRESS)
Stopped SQLAgent$SQLEXP... SQL Server Agent (SQLEXPRESS)
Running SQLBrowser SQL Server Browser
Running SQLWriter SQL Server VSS Writer
the service just wont start. This is with the plain vanilla Dockerfile as above - no customisations at all.
The run command:
docker run -d -p 1433:1433 -e sa_password=SpikePrototype2016! -e ACCEPT_EULA=Y sqlservercontainerv2
( where sqlservercontainerv2 is the image built from the dockerfile associated with microsoft/mssql-server-windows-express:latest - on the github page.)
OS:
win 10 1803
Docker:
Community Edition 18.03.1-ce-win65 (17503)
Image: not using the image- using the docker file that was used to create the image apparently.
I am using the docker file behind the image: microsoft/mssql-server-windows-express. The reason Im not using the image itself is that i cannot get any child Dockerfiles to work with the actual image , so Im just trying to understand this Dockerfile first. Its different to more recent docker files in that it doesnt use: # escape=`
Anyone got any ideas? Thanks so much in advance :->
P.S:
The guideline for container run is :
docker run -d -p 1433:1433 -e sa_password=
sa_password=
Try this instead: docker run -d -p 1433:1433 -e "sa_password=SpikePrototype2016!" -e "ACCEPT_EULA=Y" sqlservercontainerv2
The angle brackets are not significant.
Thanks i tried that, though no change in behaviour .
PS E:\spikecontainerstaging\sqlservercontainerv2> docker run -d -p 1433:1433 -p 1434:1434 -e "sa_password=SpikePrototype2016!" -e "ACCEPT_EULA=Y" sqlservercontainerv2
450576ff882aa39cf106cdbad6f01b71dce33a41621a3c53ecb8a1c9899640a7
PS E:\spikecontainerstaging\sqlservercontainerv2> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
450576ff882a sqlservercontainerv2 "powershell -Command…" 24 seconds ago Up 12 seconds 0.0.0.0:1433-1434->1433-1434/tcp practical_jones
PS E:\spikecontainerstaging\sqlservercontainerv2> docker logs 45
VERBOSE: Starting SQL Server
start-service : Failed to start service 'SQL Server (SQLEXPRESS)
(MSSQL$SQLEXPRESS)'.
At C:\start.ps1:27 char:1
The container stops within 1 minute.
I was however curious about one thing in the start.ps1 script that does not work even manually when i logged onto the container:
start-service MSSQL`$SQLEXPRESS
This powershell cannot start the service.
Is it correct that there is an escape character before what looks like an Env variable $SQLEXPRESS ?
i havent been able to confirm that this Env variable even exists in the image. Its not in the docker file so perhaps SQL installation put it there.
Can you please share your Dockerfile?
Yes, the ` is there to escape the $ which is actually part of the service name.
Here it is. (Its the Microsoft one):
FROM microsoft/windowsservercore
LABEL maintainer "Perry Skountrianos"
ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
ENV sa_password="_" \
attach_dbs="[]" \
ACCEPT_EULA="_" \
sa_password_path="C:\ProgramData\Docker\secrets\sa-password"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY start.ps1 /
WORKDIR /
RUN Invoke-WebRequest -Uri $env:sql_express_download_url -OutFile sqlexpress.exe ; \
Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; \
.\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \
Remove-Item -Recurse -Force sqlexpress.exe, setup
RUN stop-service MSSQL`$SQLEXPRESS ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose
OK, and when you docker build this the start.ps1 script is in the same directory as your Dockerfile and where you are running the docker build command from? Are there any warnings or errors during build?
No warnings during build. -i will remove image and start again. Meanwhile..
yes its in the same root directory.I just copied start.ps1 down fromthe github page. Ive rebuilt the image after a system prune. Heres the output (it used existing cached images):
PS E:\spikecontainerstaging\sqlservercontainerv2> dir
Directory: E:\spikecontainerstaging\sqlservercontainerv2
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 04/07/2018 13:22 backupdockerfile
d----- 03/07/2018 15:29 DockerPowershellScripts
d----- 03/07/2018 15:28 SQLserverDBBackup
d----- 03/07/2018 15:28 SQLServerScripts
-a---- 04/07/2018 14:06 1616 Dockerfile
-a---- 04/07/2018 13:57 4409 Dockerfile.old
-a---- 03/07/2018 10:18 2228 start.ps1
PS E:\spikecontainerstaging\sqlservercontainerv2> docker build -t sqlservercontainerv2 .
Sending build context to Docker daemon 47.18MB
Step 1/10 : FROM microsoft/windowsservercore
---> 9dbf7f740334
Step 2/10 : LABEL maintainer "Perry Skountrianos"
---> Using cache
---> 3f0cbf920c97
Step 3/10 : ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
---> Using cache
---> bfa759ebb82d
Step 4/10 : ENV sa_password="_" attach_dbs="[]" ACCEPT_EULA="_" sa_password_path="C:\ProgramData\Docker\secrets\sa-password"
---> Using cache
---> 160c2ca6b4c6
Step 5/10 : SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
---> Using cache
---> cc40311fcfaf
Step 6/10 : COPY start.ps1 /
---> Using cache
---> d6cede774a83
Step 7/10 : WORKDIR /
---> Using cache
---> a148e075d2ef
Step 8/10 : RUN Invoke-WebRequest -Uri $env:sql_express_download_url -OutFile sqlexpress.exe ; Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; Remove-Item -Recurse -Force sqlexpress.exe, setup
---> Using cache
---> f73c4ec3f844
Step 9/10 : RUN stop-service MSSQL`$SQLEXPRESS ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
---> Using cache
---> c137387cefb6
Step 10/10 : CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose
---> Using cache
---> 020bb4694e12
Successfully built 020bb4694e12
Successfully tagged sqlservercontainerv2:latest
PS E:\spikecontainerstaging\sqlservercontainerv2>
complete image rebuild; a couple of warning pertaining to .NET
Ran the container and it stopped as before with following logs:
PS E:\spikecontainerstaging\sqlservercontainerv2> docker logs 4195
VERBOSE: Starting SQL Server
start-service : Failed to start service 'SQL Server (SQLEXPRESS)
(MSSQL$SQLEXPRESS)'.
At C:\start.ps1:27 char:1
Docker image build results:
docker build -t sqlservercontainerv2 .
Sending build context to Docker daemon 47.18MB
Step 1/10 : FROM microsoft/windowsservercore
---> 9dbf7f740334
Step 2/10 : LABEL maintainer "Perry Skountrianos"
---> Running in 264e63142122
Removing intermediate container 264e63142122
---> 96c5d8101335
Step 3/10 : ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
---> Running in 43e33b62f3d6
Removing intermediate container 43e33b62f3d6
---> f81405f7dcf6
Step 4/10 : ENV sa_password="_" attach_dbs="[]" ACCEPT_EULA="_" sa_password_path="C:\ProgramData\Docker\secrets\sa-password"
---> Running in aabe383102c0
Removing intermediate container aabe383102c0
---> d70fb0e20c9b
Step 5/10 : SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
---> Running in b549d6e44742
Removing intermediate container b549d6e44742
---> 07957d83c2f0
Step 6/10 : COPY start.ps1 /
---> 0fd95810c5ba
Step 7/10 : WORKDIR /
Removing intermediate container 2b98be7bc711
---> 9327e10532e7
Step 8/10 : RUN Invoke-WebRequest -Uri $env:sql_express_download_url -OutFile sqlexpress.exe ; Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; Remove-Item -Recurse -Force sqlexpress.exe, setup
---> Running in 2f751fe66e18
Microsoft .NET Framework CasPol 4.6.1586.0
for Microsoft .NET Framework version 4.6.1586.0
Copyright (C) Microsoft Corporation. All rights reserved.
WARNING: The .NET Framework does not apply CAS policy by default. Any settings
shown or modified by CasPol will only affect applications that opt into using
CAS policy.
Please see http://go.microsoft.com/fwlink/?LinkId=131738 for more information.
Success
Microsoft .NET Framework CasPol 4.6.1586.0
for Microsoft .NET Framework version 4.6.1586.0
Copyright (C) Microsoft Corporation. All rights reserved.
WARNING: The .NET Framework does not apply CAS policy by default. Any settings
shown or modified by CasPol will only affect applications that opt into using
CAS policy.
Please see http://go.microsoft.com/fwlink/?LinkId=131738 for more information.
Success
SQL Server 2017 transmits information about your installation experience, as well as other usage and performance data, to Microsoft to help improve the product. To learn more about SQL Server 2017 data processing and privacy controls, please see the Privacy Statement.
Microsoft (R) SQL Server 2017 14.00.1000.169
Copyright (c) 2017 Microsoft. All rights reserved.
Removing intermediate container 2f751fe66e18
---> 2ee326907e7d
Step 9/10 : RUN stop-service MSSQL`$SQLEXPRESS ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
---> Running in baf27ffa70d5
Removing intermediate container baf27ffa70d5
---> 1faae1dddbaa
Step 10/10 : CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose
---> Running in 22723efd4525
Removing intermediate container 22723efd4525
---> 91c9c5a8f846
Successfully built 91c9c5a8f846
Successfully tagged sqlservercontainerv2:latest
@twright-msft Thank you, changing the password fixed my problem. Why was there no error message?
@nikolaipaul - you are right we should show an error message in the logs in this case. I'll file a bug about it.
Most helpful comment
OK yeah, the password needs to meet complexity requirements.
https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-2017