【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
相关推荐
木易 士心12 分钟前
Protocol Buffers (Protobuf) 详解
运维·服务器
百***241327 分钟前
Nginx反向代理出现502 Bad Gateway问题的解决方案
运维·nginx·gateway
q***979138 分钟前
从零到上线:Node.js 项目的完整部署流程(包含 Docker 和 CICD)
docker·容器·node.js
以琦琦为中心1 小时前
在RK3568开发板嵌入式开发中,配置NFS服务是实现与Ubuntu虚拟机之间文件共享的常用方法
linux·运维·ubuntu·rk3568
小杨互联网2 小时前
JAR逆向工程实战对比:传统工具 vs 自动化解决方案
运维·自动化·jar·jar自动逆向工具·jar逆向源码
早睡冠军候选人4 小时前
Ansible学习----管理复杂的 Play 和 Playbook 内容
运维·学习·云原生·ansible
Robpubking8 小时前
AWS 中 S3 的 server-side encryption 解释与说明
运维·aws
旦沐已成舟8 小时前
K8S中修改apiserver地址
云原生·容器·kubernetes
爱喝矿泉水的猛男11 小时前
单周期Risc-V指令拆分与datapath绘制
运维·服务器·risc-v
hakukun11 小时前
docker避免每次sudo方法
运维·docker·容器