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

 

參考:https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-configure-docker?view=sql-server-2017

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM