【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
相关推荐
虎头金猫几秒前
Beszel 轻量服务器监控:多台服务器状态统一看,搭起来比 Prometheus 省事太多
linux·运维·服务器·分布式·kafka·开源·prometheus
凌晨一点的秃头猪几秒前
在cursor里面设置免密码登录服务器理解
linux·运维·服务器
zt1985q15 分钟前
本地部署搜索引擎 Yacy 并实现外部访问
运维·服务器·网络·网络协议·搜索引擎
不做无法实现的梦~15 分钟前
桌面图标无法隐藏的解决办法
运维·服务器
量子炒饭大师16 分钟前
【Linux系统编程】Cyberpunk在霓虹丛林中构建堡垒 ——【基础开发工具(1)】一文带你初步了解 软件包管理器 并 快速上手 yum和apt 工具
java·linux·运维·apt·yum·软件包管理器
Azure DevOps25 分钟前
在Azure DevOps Server中实现用户端原地址透传(X-Forward-For)
运维·microsoft·azure·devops
草莓熊Lotso25 分钟前
【CMake】 工程实战:可执行文件从编译、链接到安装全流程深度拆解
linux·运维·服务器·网络·c++·cmake
正点原子27 分钟前
【正点原子Linux连载】 第五章 字符设备驱动开发 摘自【正点原子】ATK-DLRK3568嵌入式Linux驱动开发指南
linux·运维·驱动开发
路由侠内网穿透27 分钟前
本地部署开源 HTTP 服务器 OpenLiteSpeed 并实现外部访问
运维·服务器·网络·网络协议·http·开源
源远流长jerry29 分钟前
Linux内核之一条tcp到底占用多少内存
linux·运维·服务器·网络·网络协议·tcp/ip