SQL Server官方镜像
请参考:
https://hub.docker.com/_/microsoft-mssql-server
参考:https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-docker?view=sql-server-2017&pivots=cs1-bash
1docker search mssql
2docker pull mcr.microsoft.com/mssql/server:2017-latest
3docker pull mcr.microsoft.com/mssql/server:2019-latest
4docker pull mcr.microsoft.com/mssql/server:2022-latest
5
6-- 2017
7docker rm -f mssql2017
8docker run -d --name mssql2017 --hostname mssql2017 \
9-p 1401:1433 \
10-e "ACCEPT_EULA=Y" -e "SA_PASSWORD=lhr@zr123" \
11-e "TZ=Asia/Shanghai" \
12-e "MSSQL_PID=Enterprise" \
13-e "MSSQL_LCID=2052" \
14-e "MSSQL_COLLATION=Chinese_PRC_CI_AS" \
15-e "MSSQL_AGENT_ENABLED=true" \
16mcr.microsoft.com/mssql/server:2017-latest
17
18docker exec -it mssql2017 bash
19/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "lhr@zr123"
20sqlcmd -S 192.168.8.8,1401 -U SA -P "lhr@zr123"
21
22
23-- 2019
24docker rm -f mssql2019
25docker run -d --name mssql2019 --hostname mssql2019 \
26-p 1402:1433 \
27-e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=lhr@zr123" \
28-e "TZ=Asia/Shanghai" \
29-e "MSSQL_PID=Enterprise" \
30-e "MSSQL_LCID=2052" \
31-e "MSSQL_COLLATION=Chinese_PRC_CI_AS" \
32-e "MSSQL_AGENT_ENABLED=true" \
33mcr.microsoft.com/mssql/server:2019-latest
34
35docker exec -it mssql2019 bash
36/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "lhr@zr123"
37sqlcmd -S 192.168.8.8,1402 -U SA -P "lhr@zr123"
38
39
40-- 2022
41docker rm -f mssql2022
42docker run -d --name mssql2022 --hostname mssql2022 \
43-p 1403:1433 \
44-e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=lhr@zr123" \
45-e "TZ=Asia/Shanghai" \
46-e "MSSQL_PID=Enterprise" \
47-e "MSSQL_LCID=2052" \
48-e "MSSQL_COLLATION=Chinese_PRC_CI_AS" \
49-e "MSSQL_AGENT_ENABLED=true" \
50mcr.microsoft.com/mssql/server:2022-latest
51
52
53docker exec -it mssql2022 bash
54/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "lhr@zr123"
55sqlcmd -S 192.168.8.8,1433 -U SA -P "lhr@zr123"
56
57SELECT Name from sys.Databases
58go
59
60SELECT @@VERSION
61SELECT SERVERPROPERTY('Edition')
62go
63
64
65-- 修改sa密码
66USE [master]
67GO
68ALTER LOGIN [sa] WITH CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
69GO
70ALTER LOGIN [sa] WITH PASSWORD=N'lhr'
71GO
72
73-- 修改内存
74
75SELECT * FROM sys.configurations d
76where d.name like '%max server memory (MB)%'
77ORDER BY name ;
78GO
79
80
81
82sp_configure 'show advanced options', 1;
83GO
84RECONFIGURE WITH OVERRIDE;
85GO
86sp_configure 'max server memory (MB)', 1024;
87GO
88RECONFIGURE WITH OVERRIDE;
89GO
90
91
92-- 远程登录
93sqlcmd -S 192.168.8.8,1403 -U sa -P lhr
94sqlcmd -S 192.168.8.8,1403 -d master -h -1 -U sa -P lhr -W -Q "set nocount on;SELECT name FROM master..sysdatabases"
95
96
97-- linux客户端
98curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
99yum install -y mssql-tools unixODBC-devel mssql-cli
100
101echo "export PATH=/opt/mssql-tools/bin:$PATH" >> /root/.bashrc
102source /root/.bashrc
103
104-- 建库
105create database lhrdb COLLATE Chinese_PRC_BIN;
106
麦老师自制镜像
1nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/mssql2019:2.0 &
2nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/mssql2017:2.0 &
3nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/mssql2022:2.0 &
4
5
6docker rm -f lhrmssql2017
7docker run -d --name lhrmssql2017 -h lhrmssql2017 \
8 -p 1437:1433 -p 217:22 \
9 -v /sys/fs/cgroup:/sys/fs/cgroup \
10 --privileged=true lhrbest/mssql2017:2.0 \
11 /usr/sbin/init
12
13
14docker rm -f lhrmssql2019
15docker run -d --name lhrmssql2019 -h lhrmssql2019 \
16 -p 1439:1433 -p 219:22 \
17 -v /sys/fs/cgroup:/sys/fs/cgroup \
18 --privileged=true lhrbest/mssql2019:2.0 \
19 /usr/sbin/init
20
21
22
23docker rm -f lhrmssql2022
24docker run -d --name lhrmssql2022 -h lhrmssql2022 \
25 -p 14322:1433 -p 222:22 \
26 -v /sys/fs/cgroup:/sys/fs/cgroup \
27 --privileged=true lhrbest/mssql2022:2.0 \
28 /usr/sbin/init