Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Value cannot be null. Parameter name: userName" error when installing MSSQL 2014 Express in Docker

When I try installing MSSQL 2014 Express in Dockerfile, it fails with error "Value cannot be null. Parameter name: userName".

The following error occurred:
Value cannot be null.
Parameter name: userName

Error result: -2147467261
Result facility code: 0
Result error code: 16387

Please review the summary.txt log for further details
Microsoft (R) SQL Server 2014 12.00.5000.00
Copyright (c) Microsoft Corporation.  All rights reserved.

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS' returned a non-zero code: 1

This is how my Dockerfile looks like (irrelevant parts omitted):

FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY SQLEXPR_x64_ENU.exe ./
RUN .\SQLEXPR_x64_ENU.exe /x:extracted /u
RUN cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

The strange thing is, when I replace the last RUN command with ENTRYPOINT powershell, start the container and then run the exact same command, it works and the error isn't thrown.

The only thing I suspect to be a problem is that docker runs commands as "no user". But...

This is a result of whoami command in running container: user manager\containeradministrator

I have tried putting RUN whoami to Dockerfile to confirm my hypothesis but the output is the same.

I have no idea what else to do, so thanks for any suggestions :).

like image 879
Samuel Avatar asked Nov 30 '25 11:11

Samuel


1 Answers

So I've finally found what causes the problem. The error occurs when using powershell as default shell (SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"])

I made it work by skipping SHELL command and running installations from default command line.

RUN /SQLEXPR_x64_ENU.exe /qs /x:setup
RUN /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

MSSQL 2008, 2012 and 2016 all work ok with powershell, only 2014 has this issue.

like image 53
Samuel Avatar answered Dec 03 '25 01:12

Samuel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!