Docker 连接 SQL Server 容器非零代码:1

Docker connect SQL Server container non-zero code: 1(Docker 连接 SQL Server 容器非零代码:1)
本文介绍了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

这篇关于Docker 连接 SQL Server 容器非零代码:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)