microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.72k stars 759 forks source link

Unable to start container - CoInitializeSecurity failure #804

Open wicksipedia opened 1 year ago

wicksipedia commented 1 year ago

Hey there 👋 Getting odd container startup issues that I haven't experienced before.

Trying to work with 2022-latest, since this hasn't changed in a couple of months, I'm wondering if its a windows/docker regression.

REPOSITORY                                  TAG           IMAGE ID       CREATED         SIZE
mcr.microsoft.com/mssql/server              2022-latest   9e28798be691   2 months ago    1.6GB

When running:

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>' `
    -p 1433:1433 `
    --name sql` `
    -h sql1 `
    -d mcr.microsoft.com/mssql/server:2022-latest 

I was getting errors similar to #787

/opt/mssql/bin/permissions_check.sh: line 4: [: : integer expression expected
/opt/mssql/bin/permissions_check.sh: line 59: [: : integer expression expected

I added the CONFIG_EDGE_BUILD variable:

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>' -e 'CONFIG_EDGE_BUILD=0' `
    -p 1433:1433 `
    --name sql1 `
    -h sql1 `
    -d mcr.microsoft.com/mssql/server:2022-latest 

Now I am hitting a CoInitializeSecurity failure:

2023-01-23 10:56:00 SQL Server 2022 will run as non-root by default.
2023-01-23 10:56:00 This container is running as user mssql.
2023-01-23 10:56:00 To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2023-01-23 10:58:43 ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5)

Note: mssql on docker was working last week before updating to: Windows - 22623.1180 (Beta channel) Docker - 4.16.2 (95914)

CraigN commented 1 year ago

I've got the same issue this morning. Same image ID, running under Docker-Compose with Docker Desktop 4.16.2 but on Windows 25276.1000 (Dev channel). It doesn't appear to be an issue with the Windows build as I haven't updated.

karlmacklin commented 1 year ago

I've run into a very similar problem with the mssql-azure-edge image on Windows. Happened friday last week, January 20th. Running Windows 10, Docker 4.16.2.

First I'm met by:

db-mssql-azure-edge  | 2023/01/23 08:19:18 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.
db-mssql-azure-edge  | 2023/01/23 08:19:19 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.
db-mssql-azure-edge  | 2023/01/23 08:19:20 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.
db-mssql-azure-edge  | 2023/01/23 08:19:21 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.
db-mssql-azure-edge  | 2023/01/23 08:19:22 [launchpadd] WARNING: Failed to connect to SQL because: dial tcp 127.0.0.1:1431: getsockopt: connection refused, will reattempt connection.

Usually I get about 3 warnings before the rest of the system starts. But now there's 5 and a long delay.

Finally it crashed with:

db-mssql-azure-edge  | ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5)
db-mssql-azure-edge exited with code 1

Very strange.

I have also tried with Docker 4.15 and 4.14 and 4.13 by now, no difference. Same result. Both in powershell win10 and WSL2.

karlmacklin commented 1 year ago

My test above was with the azure-edge version. So how does my system do with the 'standard' mssql docker image?

Starting a basic mcr.microsoft.com/mssql/server:2022-latest docker image, using this command: docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest

Results in:

/opt/mssql/bin/permissions_check.sh: line 4: [: : integer expression expected
SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
/opt/mssql/bin/permissions_check.sh: line 59: [: : integer expression expected
ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5)

On both Docker Desktop 4.13.1 and 4.16.2 (latest of this writing). My colleague with Windows 11 has no problems. My guess WOULD be that there is something messed up with some recent Windows 10 update. However CraigN's comment above speaks against that theory, so I'm not sure.

Specific Windows info is: Windows 10 Pro, 22H2 OS-version 19045.2546 Windows Feature Experience Pack 120.2212.4190.0

If I use tag 2019-latest it works fine however.

molesinski commented 1 year ago

I have the same issue today, worked fine on friday. I had no issues for months before.

Windows 11 22H2 (OS Build 22621.1105) Docker 4.16.2

According to windows update history, nothing has been installed over the weekend.

karlmacklin commented 1 year ago

I have the same issue today, worked fine on friday. I had no issues for months before.

Windows 11 22H2 (OS Build 22621.1105) Docker 4.16.2

According to windows update history, nothing has been installed over the weekend.

I have a colleague running Win 11 Pro OS build 22623.1180 (seems to be same as original poster's) and he can run both azure edge container and mcr.microsoft.com/mssql/server:2022-latest fine using Docker 4.15.x.

molesinski commented 1 year ago

I found the culprit. Apparently today in the morning Windows Subsystem for Linux store app has auto updated from version 1.0.3 to version 1.1.0, which cause this problem.

Reverting back to version 1.0.3 from here https://github.com/microsoft/WSL/releases solved the issue.

karlmacklin commented 1 year ago

I found the culprit. Apparently today in the morning Windows Subsystem for Linux store app has auto updated from version 1.0.3 to version 1.1.0, which cause this problem.

Reverting back to version 1.0.3 from here https://github.com/microsoft/WSL/releases solved the issue.

great find, I installed 1.0.3 as well and it works fine

not sure why my system had opted for 1.1.0

wicksipedia commented 1 year ago

Rolling back to 1.0.3 worked for me, so I added an issue to the WSL repo

JakobRobijns commented 1 year ago

Rolling back to 1.0.3 worked for me, so I added an issue to the WSL repo

Same issue and also fixed it for me

TuanUsense commented 1 year ago

Hello, i have the same issue. Docker 4.16.3, Win 11 22H2 22621.1194, wsl 2. It failed to start docker for sqlserver 2022, but it works well with sqlserver 2019. Uninstall/reinstall docker does not work.

frasermclean commented 1 year ago

Experienced this issue too. Windows OS build 22623.1245 . Using SQL server 2019 seems to work fine.

DeathNet123 commented 1 year ago

I am encountering the same issue, SQL server 2019 was working fine at the start but now it just stuck at the upgrade

2023-02-07 16:58:50.73 spid9s      Database 'msdb' running the upgrade step from version 902 to version 903.
2023-02-07 16:58:50.74 spid9s      Database 'msdb' running the upgrade step from version 903 to version 904.

The server get's ready for the connection after like 5-6 minutes don't know what to look into

Windows 11 Version 22H2 Build 25281.1000

WSL version: 1.1.2.0 Kernel version: 5.15.83.1 WSLg version: 1.0.49

cirolosapio commented 1 year ago

Reverting back to version 1.0.3 from here https://github.com/microsoft/WSL/releases solved the issue.

@molesinski how do you reverted the wsl version?

Rolling back to 1.0.3 worked for me, so I added an issue to the WSL repo

@wicksipedia can you please share the issue?

same problem with WSL 1.1.2

wicksipedia commented 1 year ago

@molesinski how do you reverted the wsl version?

Data integrity isn’t guaranteed AFAIK. I was able to download 1.0.3 from the WSL repo then run:

$Package = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemforLinux -AllUsers 
Remove-AppxPackage $Package -AllUsers
Add-AppxPackage .\Microsoft.WSL_1.0.3.0_x64_ARM64.msixbundle

@wicksipedia can you please share the issue?

same problem with WSL 1.1.2

It’s in the comments above but it has been closed as a dupe.

The WSL team are working on https://github.com/microsoft/WSL/issues/9508

cirolosapio commented 1 year ago

I checked with WSL 1.1.3 and it seems to work

Versione WSL: 1.1.3.0
Versione kernel: 5.15.90.1
Versione WSLg: 1.0.49
Versione MSRDC: 1.2.3770
Versione Direct3D: 1.608.2-61064218
Versione DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
versione Windows: 10.0.25300.1000
ledjon-behluli commented 1 year ago

Even with WSL 1.1.3 the latest image for sql-server 2022 doesn't work for me. As with others, 2019 does work!

WSL version: 1.1.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.49
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1641
SaxonDruce commented 1 year ago

I was having the same problem as @ledjon-behluli that it still didn't work with WSL 1.1.3, but I noted that it had worked for @cirolosapio

I checked my wsl --version:

WSL version: 1.1.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.49
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1574

And saw that I was on the same windows build version 22000 as @ledjon-behluli while @cirolosapio is on build version 25300.

I checked for and applied two windows updates:

  1. 2023-02 Cumulative Update for Windows 11 for x64-based Systems (KB5022905)
  2. Windows 11, version 22H2

The first update took me to 10.0.22000.1641, and sql-server 2022 still didn't work.

The second update took me to 10.0.22621.1265, and at that point it finally worked for me!

royberris commented 1 year ago

Can confirm @SaxonDruce comment, updating Windows to 22H2 fixes the issue.

wsl --version

WSL version: 1.1.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.49
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1265
aliasadidev commented 1 year ago

I installed 1.1.5 and it works correctly with MSSQL 2022 docker image.

ledjon-behluli commented 1 year ago

I can confirm that upgrading to WSL 1.1.5 solved the issue with the sql-server 2022 image, even while still being on Windows 11 21H2

xorinzor commented 1 year ago

After updating to WSL 1.1.6 it worked for me, then after installing a windows update and rebooting it stopped working again. Specifically mssql 2022, 2019 works.

pablocastilla commented 1 year ago

the same here. Using 1.1.6 with the latest windows 11 doesn´t work.

dazinator commented 1 year ago

same here, using 1.1.6 with latest windows 11 = not working.

InteXX commented 1 year ago

I'm running WSL v2 on Win11, attempting to start the latest SQL 2022 image as of today. I also encountered the error:

CoInitializeSecurity failure

I was able to get it working by switching to the Hyper-V based engine in the Docker Desktop settings. (This was my first image on a new install, so there was no impact on existing infrastructure to consider. YMMV.)

KerasirovED commented 1 year ago

mcr.microsoft.com/mssql/server:2022-latest don't work for me as well 🫤 WSL 1.1.6 & Windows 11

docker logs sq1

SQL Server 2022 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5)

wsl --vesion

WSL version: 1.1.6.0
Kernel version: 5.15.90.1
WSLg version: 1.0.50
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1413
snavarropino commented 1 year ago

Same here, unable to run sql 22

image

EwanMcP commented 1 year ago

Same here. Remembered the solution from last time - reverted back from (pre-release) WSL 1.2.0.0 to last non-pre-release version 1.1.3 - and voila. Powershell instructions to un/reinstall above thanks to @wicksipedia

snavarropino commented 1 year ago

Other option is switching to hyper-v backend, but you are gonna loose your data

BerendWouters commented 1 year ago

Encountering the same issue, reverting to 2019-latest seems to be working.

bb-avi commented 1 year ago

Encountering the same issue: ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5) WSL Version: 1.2.0.0 Docker Desktop Version: 4.18.0

Remedy: Revert WSL to version 1.1.6.0

deividferreira commented 1 year ago

Encountering the same issue: ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5) WSL Version: 1.2.0.0 Docker Desktop Version: 4.18.0

Remedy: update WSL to version 1.2.1.0

dparraho commented 1 year ago

I updated to https://github.com/microsoft/WSL/releases/tag/1.2.1 as @deividferreira suggested and worked!

Previous WSL Version: 1.2.0.0

ak-shanith commented 1 year ago

Fixed by updating WSL + Docker Desktop versions.

WSL version: 1.2.1.0 Docker Desktop Version: 4.18.0

ancollet commented 1 year ago

+1 Fixed by updating WSL + Docker Desktop versions.

WSL version: 1.2.1.0 Docker Desktop Version: 4.18.0

jhm-ciberman commented 1 year ago

Fixed here! 🎉

Setup that fails Windows version: (winver) Windows 11 22H2 Build 226221

$ wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1555

Steps to fix

  1. Update docker to latest (I don't think it's required, but just in case). This is the version after I updated:
    $ docker --version
    Docker version 20.10.24, build 297e128
  2. Update WSL to latest pre-release. (If you read this in the future, just ensure you are using 1.2.1 or later.
$ wsl --update --pre-release
Checking for updates.
Updating Windows Subsystem for Linux to version: 1.2.1.

Note: if I run again wsl --version it still shows 1.2.0.0, but it's upgraded.

Note2: In my specific case I deleted the volume and recreated it, but I don't think that's necessary at all.

jafin commented 1 year ago
$ wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1485

$ docker --version
Docker version 20.10.24, build 297e128
(Docker Windows 4.18)

Could not get any existing MSSQL 2022 image to run (Error: ERROR: CoInitializeSecurity failure. (HRESULT 0x800706b5)) Downgraded to image 2019-CU19-ubuntu-20.04 which is working

May attempt the option above from @jhm-ciberman about upgrading to prerelease wsl and try 2022 again. EDIT: Updated WSL prerelease 1.2.2 upgraded to MSSQL20222 and appears all working 🤞

eazytracer commented 1 year ago

Can confirm it's working for me after updating both Docker and WSL. Would be nice to know what the actual underpinning issue is so we don't have to worry about reverting every time there is an update, but I'm just happy it's working right now.

Thanks to others above for the suggestions on using pre-release wsl

$ wsl --version
WSL version: 1.2.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1555

$ docker --version
Docker version 20.10.24, build 297e128
giuseppecapasso commented 1 year ago

Can confirm it's working for me after updating both Docker and WSL. Would be nice to know what the actual underpinning issue is so we don't have to worry about reverting every time there is an update, but I'm just happy it's working right now.

Thanks to others above for the suggestions on using pre-release wsl

$ wsl --version
WSL version: 1.2.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1555

$ docker --version
Docker version 20.10.24, build 297e128

thanks for the suggestion, I had the same problem with wsl 1.2.0 and I solved it by updating the wsl to version 1.2.3

drdreo commented 1 year ago

Fixed here! 🎉

Setup that fails Windows version: (winver) Windows 11 22H2 Build 226221

$ wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1555

Steps to fix

  1. Update docker to latest (I don't think it's required, but just in case). This is the version after I updated:
$ docker --version
Docker version 20.10.24, build 297e128
  1. Update WSL to latest pre-release. (If you read this in the future, just ensure you are using 1.2.1 or later.
$ wsl --update --pre-release
Checking for updates.
Updating Windows Subsystem for Linux to version: 1.2.1.

+1 Thanks a ton for the suggestion. Using the wsl pre-release 1.2.4 and docker desktop 4.18.0 makes sqlserver start again.