Docker connect SQL Server container non-zero code: 1

Viewed 7443

I'm trying to create a SQL Server container from a docker-compose.yml but when I run it, it directly stops with some errors. Note: it's running on an Apple M1 chip with docker Preview

docker-compose.yml:

version: "3.7"
services:
  sql-server-db:
    container_name: sql-server-db
    image: mcr.microsoft.com/mssql/server:2019-latest
    ports: 
      - "1433:1433"
    environment: 
      SA_PASSWORD: "ApplePassDockerConnect"
      ACCEPT_EULA: "Y"

The errors I'm getting:

sql-server-db | /opt/mssql/bin/sqlservr: Invalid mapping of address 0x40092b8000 in reserved address space below 0x400000000000. Possible causes:

sql-server-db | 1) the process (itself, or via a wrapper) starts-up its own running environment sets the stack size limit to unlimited via syscall setrlimit(2);

sql-server-db | 2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2);

sql-server-db | 3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout.

sql-server-db |

sql-server-db exited with code 1

4 Answers

You cant really use mcr.microsoft.com/mssql/server:2019-latest containers on M1 because MSSQL DB does not support ARM architecture. The only way I found - is to use Azure SQL container that supports ARM and can be run on M1.

Here my docker-compose.yml config example:

version: "3.9"

services:
    # Database instance
    mssql:
      image: mcr.microsoft.com/azure-sql-edge:latest
      volumes:
        - events_mssql:/var/opt/mssql
      ports:
        - 1433:1433
      environment:
        - ACCEPT_EULA=1
        - MSSQL_SA_PASSWORD=Passw@rd

volumes:
    events_mssql:

You will be able to connect to this DB using username: sa, password: Passw@rd and database: master. If you want other db name - you can create a new one using SQL: CREATE DATABASE TestDB

This database has the same API as MSSQL DB, so it works with pyodbc (not supported on M1) and pymssql libraries.

If you are using it locally on your M1 machine - consider using pymssql library for connection to Azure SQL DB. Here my answer on issue with pyodbc https://stackoverflow.com/a/66919686/11515610

As others have noted, Azure SQL Edge Server is a workaround for the M1 issues of MSSQL Server. However, at the moment, the :latest tag of Azure SQL Edge Server has the same segfault as MSSQL server. mcr.microsoft.com/azure-sql-edge:1.0.6 works on M1, though.

docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge:1.0.6

So...this may not be related to your particular issue. I have a feeling it won't fix it for you, because your issue sounds much lower level (as you suspect) but it's worth a shot.

I tried copy-pasting your exact docker-compose file and running it on my machine (windows desktop), I also get exited with code 1.

The only thing that seemed to fix it was using a more complex password.

I tested this multiple times in a row...I tested your password, and it failed. I tested a complex password, and it worked fine.

So I suggest using a more complex password. The password I tested with was 6Xy3LkV7!9lo2^h

Related