【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
相关推荐
7177776 小时前
2026 中国企业 DevOps 平台怎么选:从排名诉求回到可核验的选型维度
运维·devops
这里是北京7 小时前
SQL 窗口函数 LAST_VALUE 取错值?从设备巡检报表看懂 ROWS 与 RANGE
数据库·sql
信安IT租赁7 小时前
小公司服务器的自启动脚本:用 systemd 做成服务,开机自动跑
linux·运维·服务器
东鹏特饮7 小时前
Docker 容器技术详细指南
运维·docker·容器
我命由我123458 小时前
Excel - Excel 固定列,滚动时该列始终可见
运维·学习·职场和发展·excel·职场发展·运维开发·学习方法
Julien20048 小时前
管理机密(二)
linux·运维·服务器·学习方法
中科米堆9 小时前
航空航天自动化 3D 尺寸检测方案|精密零部件三维扫描形位公差检测-CASAIM
运维·3d·自动化
Huangjin007_9 小时前
【Linux 系统篇(四十四)】线程(五):线程互斥:从共享资源到互斥锁
linux·运维·服务器
xiangyun619 小时前
Ubuntu 网络排障决策树(5):SYN 到了网卡,为什么既没有 SYN-ACK 也没有 RST
linux·运维·服务器·网络·安全·ubuntu
吴声子夜歌9 小时前
Kubernetes进阶实战——网络模型与网络策略(二)
网络·容器·kubernetes