Docker 上的 SQL Server
本指南快速概述了如何在 Docker 容器中设置和运行 Microsoft SQL Server,包括拉取镜像、启动服务器、连接以及创建测试数据库。
¥This guide provides a quick overview on setting up and running Microsoft SQL Server in a Docker container, including pulling the image, starting the server, connecting, and creating a test database.
Prisma 7.0.0 更新了 Node.js 的最低要求:
¥Prisma 7.0.0 has updated minimum Node.js requirements:
-
Node.js 20:= 20.19.0
-
Node.js 22:= 22.12.0
-
Node.js 24:= 24.0.0+
如果你使用 Prisma 7.0.0 或更高版本并搭配 Docker,请确保你的应用的 Docker 基础镜像使用 Node.js 22 或 24。更新你的 Dockerfile,使用 node:22-alpine 或 node:24-alpine 镜像,而不是旧的 Node.js 20 镜像。
¥If you're using Prisma 7.0.0 or higher with Docker, ensure your application's Docker base image uses Node.js 22 or 24. Update your Dockerfile to use node:22-alpine or node:24-alpine instead of older Node.js 20 images.
要使用 Docker 运行 Microsoft SQL Server 容器映像:
¥To run a Microsoft SQL Server container image with Docker:
-
安装并设置 Docker
¥Install and set up Docker
-
在终端中运行以下命令来下载 Microsoft SQL Server 2019 映像:
¥Run the following command in your terminal to download the Microsoft SQL Server 2019 image:
docker pull mcr.microsoft.com/mssql/server:2019-latest -
创建容器映像的实例,将
SA_PASSWORD的值替换为你选择的密码:¥Create an instance of the container image, replacing the value of
SA_PASSWORDwith a password of your choice:docker run --name sql_container -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassword' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest -
按照 Microsoft 的说明连接 SQL Server 并使用
sqlcmd工具,将镜像名称和密码替换为你自己的。¥Follow Microsoft's instructions to connect to SQL Server and use the
sqlcmdtool, replacing the image name and password with your own. -
在
sqlcmd命令提示符下,创建一个新数据库:¥From the
sqlcmdcommand prompt, create a new database:CREATE DATABASE quickstart
GO -
运行以下命令检查数据库是否已成功创建:
¥Run the following command to check that your database was created successfully:
sp_databases
GO
连接 URL 凭据
¥Connection URL credentials
根据此示例,你的凭据是:
¥Based on this example, your credentials are:
-
用户名:sa
¥Username: sa
-
密码:我的密码
¥Password: myPassword
-
数据库:快速开始
¥Database: quickstart
-
港口:1433
¥Port: 1433