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
The following sections explain both scenarios. You can connect to the SQL Server instance on your Docker machine from any external Linux, Windows, or macOS tool that supports SQL connections. Some common tools include: The following example uses sqlcmd to connect to SQL Server running in a Docker container.
Starting with SQL Server 2017, the SQL Server command-line tools are included in the container image. If you attach to the image with an interactive command-prompt, you can run the tools locally. Use the docker exec -it command to start an interactive bash shell inside your running container.
If you can't connect to the SQL Server instance running in your container, try the following tests: Make sure that your SQL Server container is running by looking at the STATUS column of the docker ps -a output. If not, use docker start <Container ID> to start it.
This article talks about common errors seen when deploying and using SQL Server Docker containers, and provide troubleshooting techniques to help resolve the issue. If you get errors for any docker commands, make sure that the docker service is running, and try to run with elevated permissions.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With