You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux版SQL Server Docker容器运行数秒后停止求助

Fix: SQL Server Linux Container Stops After A Few Seconds

Let's break down how to diagnose and fix this issue—container exits almost always leave clear clues in the logs, so let's start there.

Step 1: Check Container Logs

First, pull the logs from your stopped container to see exactly why it's failing:

docker logs sql1

This will show you the specific error message that's causing the container to exit immediately.

Common Causes & Fixes

1. SA Password Doesn't Meet Complexity Requirements

SQL Server enforces strict password rules for the sa account: your password must be at least 8 characters long, and include three of the four categories: uppercase letters, lowercase letters, numbers, and non-alphanumeric symbols.

Your current password dockermssql only uses lowercase letters and numbers (two categories), which violates this rule.

Fix: Use a compliant password, then recreate the container:

# Delete the existing container first
docker rm sql1

# Launch with a valid password (example: Docker@Mssql123)
docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Docker@Mssql123" -p 1433:1433 -v sqlvlm:/var/opt/mssql --name sql1 -d microsoft/mssql-server-linux

2. Volume Permissions Issue

The volume sqlvlm you're mounting might have incorrect permissions that prevent the SQL Server process (running as user mssql with UID 10001) from accessing /var/opt/mssql.

Fix: Test without the volume first to confirm:

docker rm sql1
docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Docker@Mssql123" -p 1433:1433 --name sql1 -d microsoft/mssql-server-linux

If the container stays running, the volume is the problem. Recreate the volume to reset permissions:

docker stop sql1 && docker rm sql1
docker volume rm sqlvlm
docker volume create sqlvlm

# Restart the container with the fresh volume
docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Docker@Mssql123" -p 1433:1433 -v sqlvlm:/var/opt/mssql --name sql1 -d microsoft/mssql-server-linux

3. Insufficient Memory

SQL Server requires a minimum of 2GB of memory to run. If your host machine or container doesn't have enough allocated, the process will crash.

Fix: Allocate at least 2GB of memory to the container:

docker rm sql1
docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Docker@Mssql123" -p 1433:1433 -v sqlvlm:/var/opt/mssql --name sql1 --memory 2g -d microsoft/mssql-server-linux

Bonus: Use the Official Up-to-Date Image

Note that microsoft/mssql-server-linux is an older, deprecated image. Microsoft now hosts the official SQL Server Linux images on the Microsoft Container Registry (MCR). For better compatibility and support, use mcr.microsoft.com/mssql/server instead:

docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Docker@Mssql123" -p 1433:1433 -v sqlvlm:/var/opt/mssql --name sql1 --memory 2g -d mcr.microsoft.com/mssql/server:latest

内容的提问来源于stack exchange,提问作者Ricardo Villagrana

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:50:40