1.服务器需要大于2G内存。如果不够则可能无法正常启动,查看日志报如下错误:

This program requires a machine with at least 2000 megabytes of memory

2.获取sqlserver镜像

docker pull mcr.microsoft.com/mssql/server:2017-latest

镜像下载成功后,运行镜像

docker run -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -e MSSQL_SA_PASSWORD="sa" -e MSSQL_TCP_PORT=1234 -p 1234:1234 --name sqlserver -d mcr.microsoft.com/mssql/server:2017-latest

运行容器报错:

SQL Server 2019 will run as non-root by default.

This container is running as user root.

To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.

The SQL Server End-User License Agreement (EULA) must be accepted before SQL

Server can start. The license terms for this product can be downloaded from

http://go.microsoft.com/fwlink/?LinkId=746388.

You can accept the EULA by specifying the --accept-eula command line option,

setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.

3.登录sqlserver容器

docker exec -it sqlserver "bash"

4.连接sqlserver

/opt/mssql-tools/bin/sqlcmd -S localhost,1234 -U SA -P 'Lc19951127.'

5.执行sql

英文的操作系统  对于有中文的  我定义类型  nvarchar(100)

插入时:

insert into users values(N'张三');

go

这个是docker for windows 安装的,接下来我会去mac里具体使用

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐