【Docker Install SQL Server】

Docker Install SQL Server

Docker pull

first step pull image: https://hub.docker.com/r/microsoft/mssql-server

bash 复制代码
docker pull mcr.microsoft.com/mssql/server

Docker run

bash 复制代码
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -e "MSSQL_PID=Evaluation" -p 1433:1433  --name mssql2022 -d mcr.microsoft.com/mssql/server

Environment Variables

You can use environment variables to configure SQL Server on Linux Containers.

ACCEPT_EULA confirms your acceptance of the End-User Licensing Agreement.

MSSQL_SA_PASSWORD is the database system administrator (userid = 'sa') password used to connect to SQL Server once the container is running. Important note: This password needs to include at least 8 characters of at least three of these four categories: uppercase letters, lowercase letters, numbers and non-alphanumeric symbols.

MSSQL_PID is the Product ID (PID) or Edition that the container will run with. Acceptable values:

  • Developer : This will run the container using the Developer Edition (this is the default if no -MSSQL_PID environment variable is supplied)
  • Express : This will run the container using the Express Edition
  • Standard : This will run the container using the Standard Edition
  • Enterprise : This will run the container using the Enterprise Edition
  • EnterpriseCore : This will run the container using the Enterprise Edition Core : This will run the container with the edition that is associated with the PID

Docker exec

bash 复制代码
docker exec -it mssql2022 "bash"

use sqlcmd connect sql server

bash 复制代码
mssql@ecf27c316472:/$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P yourPassword
1> select @@version
2> go
                                                                                                                                                                                                                                             
Microsoft SQL Server 2022 (RTM-CU13) (KB5036432) - 16.0.4125.3 (X64)
        May  1 2024 15:05:56
        Copyright (C) 2022 Microsoft Corporation
        Developer Edition (64-bit) on Linux (Ubuntu 22.04.4 LTS) <X64>

create new database

sql 复制代码
CREATE DATABASE TestDB;

SELECT Name from sys.databases;

GO

create new table

sql 复制代码
USE TestDB;

CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT);

INSERT INTO Inventory VALUES (1, 'banana', 150); 
INSERT INTO Inventory VALUES (2, 'orange', 154);

GO

query data

sql 复制代码
SELECT * FROM Inventory WHERE quantity > 152;

GO
相关推荐
骑着蜗牛撵大象3275 小时前
MySQL 8.0 迁移后 SQL 变慢:执行计划里 3 类被忽略的成本差异
android·数据库·sql·mysql·优化器·执行计划
方便面不加香菜6 小时前
Docker Container --容器及容器的操作案例详解
运维·docker·容器
zhengfei6118 小时前
Go-fastdfs /reload 未授权访问: 有效PoC
数据库·sql
AR-26710-9 小时前
Linux Day32——实操五类资源告急排查
linux·运维
大维9 小时前
DBX 实测:从 SQLite 查询到 MiniMax-M3 自然语言生成 SQL
数据库·sql·sqlite
skywalk816310 小时前
hive 常驻集群:像 OSPF 一样在线,像 git 一样可信
运维·人工智能·hive
景煜拾年11 小时前
InnoAI SQL 助手
运维·数据库·笔记·sql
无人生还别怕12 小时前
如何搭建docker仓库(轻量级)registry
linux·运维·docker·云原生·容器·registry·openanolisos
分布式存储与RustFS12 小时前
Hudi 表想摆脱 HDFS 绑定?用 Spark + Hudi 直接写进 RustFS
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
zhengfei61113 小时前
CVE-2026-98432:Linux 内核 TCP 释放后重用漏洞,CVSS 9.8 但补丁覆盖极不均衡
linux·运维·tcp/ip