作为概念证明,我试图在microsoft / windowsservercore基本映像上设置一个运行SQL Express以及其他一些服务的docker容器。
我已设法达到可以毫无问题地构建映像的程度。但是,当我尝试运行该映像时,收到以下错误消息,该消息无法使出现以下内容:
PS C:\Docker Data Directory\SQL Test> docker run sqltest --name sqltest_container -p 1433:1433
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 1afb908fe2902885211f24c7fd2f9817122e7a1
dd67008eebd0f4c63e31e3ddf encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file
specified. (0x2) extra info: {"CommandLine":"--name sqltest_container -p 1433:1433","WorkingDirectory":"C:\\install","CreateStdInPipe
":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
我的Dockerfile看起来像这样:
# Starts with the windows servercore base image
FROM microsoft/windowsservercore
# Exposes port 1433
EXPOSE 1433
# Sets the Working Directory
WORKDIR /install
# Downloads SQL Express Installer
RUN powershell wget https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe -OutFile sqlexpr_x64_enu.exe
# Installs Thw SQL Express Installer
RUN /install/sqlexpr_x64_enu.exe /q /x:/install/setup
# Add the SQL Test Installation Files (C:/SQLTest/SQLInstall/configurationfile.ini)
ADD SQLTest/SQLInstall C:/SQLTest/SQLInstall
#Installs SQL Express
RUN /install/setup/setup.exe /q /IACCEPTSQLSERVERLICENSETERMS /ConfigurationFile=C:/SQLTest/SQLInstall/configurationfile.ini
我的configurationfile.ini看起来像这样:
[OPTIONS]
ACTION = "Install"
UPDATEENABLED = "False"
USEMICROSOFTUPDATE = "False"
FEATURES = SQLENGINE
INSTANCEDIR = "C:\Program Files\Microsoft SQL Server"
INSTANCEID = "SQLExpress"
INSTANCENAME = "SQLExpress"
AGTSVCSTARTUPTYPE = "Manual"
SQLSVCSTARTUPTYPE = "Automatic"
FILESTREAMLEVEL = "0"
SQLSVCINSTANTFILEINIT = "True"
SQLSYSADMINACCOUNTS = "BUILTIN\ADMINISTRATORS"
TCPENABLED = "0"
NPENABLED = "0"
我也尝试过使它与许多教程一起使用,但是最后,我总是遇到“系统找不到指定的文件”错误消息。
这时我最好的猜测是,SQL Express需要某种尚未安装的高级工具。但是令我困惑的是为什么我可以构建图像而不运行图像。
任何对此问题的见解将不胜感激。
附加信息2018年10月17日
我现在一直在努力,并注意到在Dockerfile的末尾,SQL Server SQLEXPRESS Service存在,但处于停止状态。
Step 13/13 : RUN powershell get-service "MSSQL$*"
---> Running in 6aa3926abd3a
Status Name DisplayName
------ ---- -----------
Stopped MSSQL$SQLEXPRESS SQL Server (SQLEXPRESS)
我试图使它运行,并在Dockerfile中添加以下命令...
RUN powershell start-service "MSSQL`$SQLEXPRESS"
...但是,这只会生成以下错误消息,我也无法找到以下错误消息:
start-service : Failed to start service 'SQL Server (SQLEXPRESS)
(MSSQL$SQLEXPRESS)'.
At line:1 char:1
+ start-service MSSQL`$SQLEXPRESS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceControl
ler:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands
.StartServiceCommand
有人可以帮我吗?现在,这真的让我感到绝望...
更新2018年10月31日
好的,所以我弄清楚了“系统找不到指定的文件”错误背后的问题是什么
问题是“ docker run”命令中最终出现的简单语法错误,最终导致此误导性错误消息。
我使用的语法是:
docker run sqltest --name sqltest_container -p 1433:1433
但是,正确的语法是:
docker run --name sqltest_container -p 1433:1433 sqltest
现在我可以运行该容器,但是SQL Express Service不在其中运行。我已经确认该服务存在,但是它不会自动启动,因此尝试手动启动它会产生以下错误消息:
Step 9/11 : RUN powershell (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
---> Running in 6b2f50c860ee
SQLEXPRESS
Removing intermediate container 6b2f50c860ee
---> 14a4b7d42cd7
Step 10/11 : RUN powershell get-service "MSSQL$*"
---> Running in d8fba119d1ea
Status Name DisplayName
------ ---- -----------
Start... MSSQL$SQLEXPRESS SQL Server (SQLEXPRESS)
Removing intermediate container d8fba119d1ea
---> e656776ca44f
Step 11/11 : RUN powershell start-service "MSSQL`$SQLEXPRESS"
---> Running in 9f66a24a99c1
start-service : Failed to start service 'SQL Server (SQLEXPRESS)
(MSSQL$SQLEXPRESS)'.
At line:1 char:1
+ start-service MSSQL`$SQLEXPRESS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceControl
ler:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands
.StartServiceCommand