Docker 连接 SQL Server 容器非零代码:1
我正在尝试从 docker-compose.yml
创建一个 SQL Server 容器,但是当我运行它时,它直接停止并出现一些错误.注意:它在带有 docker Preview 的 Apple M1 芯片上运行
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:
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"
我遇到的错误:
sql-server-db |/opt/mssql/bin/sqlservr:0x4000000000000 以下保留地址空间中地址 0x40092b8000 的无效映射.可能的原因:
sql-server-db | /opt/mssql/bin/sqlservr: Invalid mapping of address 0x40092b8000 in reserved address space below 0x400000000000. Possible causes:
sql-server-db |1) 进程(本身,或通过包装器)启动自己的运行环境,通过 syscall setrlimit(2) 将堆栈大小限制设置为无限制;
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) 进程(本身,或通过包装器)调整自己的执行域,并通过系统调用个性(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 通过调整 sysctl 旋钮 vm.legacy_va_layout 故意将系统设置为在旧版 VA 布局模式下运行.
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 |
sql-server-db 退出,代码为 1
sql-server-db exited with code 1
推荐答案
你不能真正在 M1 上使用 mcr.microsoft.com/mssql/server:2019-latest
容器,因为 MSSQL DB 不支持ARM架构.我发现的唯一方法是使用支持 ARM 并且可以在 M1 上运行的 Azure SQL 容器.
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.
这里是我的 docker-compose.yml
配置示例:
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:
您将能够使用用户名:sa
、密码:Passw@rd
和数据库:master
连接到此数据库.如果您想要其他数据库名称 - 您可以创建一个新的 使用 SQL:CREATE DATABASE TestDB
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
该数据库具有与 MSSQL DB 相同的 API,因此它适用于 pyodbc
(M1 不支持)和 pymssql
库.
This database has the same API as MSSQL DB, so it works with pyodbc
(not supported on M1) and pymssql
libraries.
如果您在 M1 机器上本地使用它 - 考虑使用 pymssql
库连接到 Azure SQL DB.这是我对 pyodbc
问题的回答 https://stackoverflow.com/a/66919686/11515610
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
相关文章