docker server 容器连接sql_Docker下安装Sqlserver(mssql)

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里具体使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值