升级到 WSL2 后映射卷时 MSSQL 容器无法启动

MSSQL container fails to start when mapping volumes after upgrading to WSL2

在我将 Docker 桌面更改为使用 WSL2 后,我无法使用 Docker-compose 启动 mssql 映像。

如果我不映射容器启动的卷。

Docker-撰写

services:
  db:
    image: "mcr.microsoft.com/mssql/server:2019-latest"
    container_name: mssql
    environment:
        SA_PASSWORD: "***********"
        ACCEPT_EULA: "Y"
    ports:
    - 1433:1433
    volumes:
    - ~/docker/sql/mssql/:/var/opt/mssql/
    - ~/docker/sql/sqlserver/:/var/opt/sqlserver/
    healthcheck:
      test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
      interval: 30s
      timeout: 30s
      retries: 3

错误

** ERROR: [AppLoader] Failed to load LSA: 0xc0070102
AppLoader: Exiting with status=0xc0070102
This program has encountered a fatal error and cannot continue running at Tue Dec 15 13:49:34 2020
The following diagnostic information is available:

Reason: 0x00000006
Message: Termination of \SystemRoot\system32\AppLoader.exe was due to fatal error 0xC0000001
Address: 0x3fffb0c551f1
Stack Trace:
file://package4/windows/system32/sqlpal.dll+0x000000000030E7D9
file://package4/windows/system32/sqlpal.dll+0x000000000030C769
file://package4/windows/system32/sqlpal.dll+0x0000000000255F1D
file://package4/windows/system32/sqlpal.dll+0x00000000002551F1
file://package4/windows/system32/sqlpal.dll+0x0000000000254A72
file://package4/windows/system32/sqlpal.dll+0x0000000000254B4B
file://package4/windows/system32/sqlpal.dll+0x0000000000202FE2
file://package4/windows/system32/sqlpal.dll+0x0000000000347898
file:///windows/system32/AppLoader.exe+0x0000000000003C90
file:///Windows/SYSTEM32/KERNEL32.DLL+0x0000000000014414
file:///windows/system32/ntdll.dll+0x0000000000075541
<unknown>+0x00000000FC3FE000
Process: 10 - sqlservr
Thread: 39 (application thread 0x68)
Instance Id: 7cfc9545-c829-4a7e-a461-83b481fe05e3
Crash Id: b747c621-d4e2-46ed-9122-f14a8d54386a
Build stamp: fd4eb1565f159d8f4b2d49c48e96d5797508c8bc5f222def3def149a28435962
Distribution: Ubuntu 18.04.5 LTS
Processors: 8
Total Memory: 13339308032 bytes
Timestamp: Tue Dec 15 13:49:34 2020

Ubuntu 18.04.5 LTS
Capturing core dump and information to /var/opt/mssql/log...
/bin/cat: /proc/10/maps: Permission denied
/bin/cat: /proc/10/environ: Permission denied
/usr/bin/find: '/proc/10/map_files': Permission denied
/usr/bin/find: '/proc/10/map_files': Permission denied
/usr/bin/find: '/proc/10/map_files': Permission denied
/usr/bin/find: '/proc/10/map_files': Permission denied
dmesg: read kernel buffer failed: Operation not permitted
/usr/bin/timeout: failed to run command '/bin/journalctl': No such file or directory
/usr/bin/timeout: failed to run command '/bin/journalctl': No such file or directory
Tue Dec 15 13:49:36 UTC 2020 Capturing program information
Tue Dec 15 13:49:36 UTC 2020 Attempting to capture a dump with paldumper for pid 10
WARNING: Capture attempt failure detected
Attempting to capture a filtered dump with paldumper for pid 10
WARNING: Attempt to capture dump failed. Reference /var/opt/mssql/log/core.sqlservr.10.temp/log/paldumper-debug.log for details

Tue Dec 15 13:49:36 UTC 2020 Attempting to capture a dump with gdb
Tue Dec 15 13:49:36 UTC 2020 Captured a dump with gdb
Tue Dec 15 13:49:36 UTC 2020 Capturing program binaries
Tue Dec 15 13:49:36 UTC 2020 Compressing the dump files

wsl --list --verbose

  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2

the documentation 所述,无法映射整个 /var/opt/mssql 文件夹,但您可能想要映射包含 db 文件的数据子目录 /var/opt/mssql/data,那些你可以毫不费力地映射的

...Host volume mapping for Docker on Windows does not currently support mapping the complete /var/opt/mssql directory. However, you can map a subdirectory, such as /var/opt/mssql/data to your host machine...