[Windows Container] SQL Server

I've been a long time not play with Window Container.Today I just saw an article which introduces the SQL Server Container how to used.Therefore I doing a practice follow by this article.Due to operation system was reset so that I reinstall the Window Container by the way.

1.Install Windows Container

Power Shell execute the following script
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable-WindowsOptionalFeature -Online -FeatureName containers -All

ps:Window10 required  14393.222 or than this version,To restart after being installed.

2.Install Dock

There are two ways to do that.

1.To reference official site No.2.Install by command.

*2.Install by Dock for Windows (.exe) ps:I used this way.


After installed, Switching Windows Container  

More about Dock for Windows as below.

3.Install SQL Server Container

docker pullmicrosoft/mssql-server-windows

Create container

Create a container naming as SQLTest then set the local path to Container which used for import backup.

docker run -it --name SQLTest -d -p 1433:1433 -e sa_password=kim123 -e ACCEPT_EULA=Y -v D:/Temp/Database/:c:/DB/ microsoft/mssql-server-windows

If you knew the NAT ip range at first.Your set the ip at startup.

 docker run -it --name SQLTest --ip 172.25.171.182 -d -p 1433:1433 -e sa_password=kim123 -e ACCEPT_EULA=Y -v D:/Temp/Database/:c:/DB/ microsoft/mssql-server-windows


ps:The default NAT setting

 docker inspect  nat


If you are like me not have the ability to compute the subnet IP range.You can use the following link.


import backup.bak

docker exec SQLTest SqlCmd -E -S 172.25.171.182 -Q "RESTORE DATABASE [UnderBingo] FROM  DISK = N'C:\db\UnderBingo.bak' WITH  FILE = 1
,  MOVE N'UnderBingo' TO N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\UnderBingo.mdf'
,  MOVE N'UnderBingo_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\UnderBingo_log.ldf'
,  NOUNLOAD,  STATS = 5"


Afer imported, Run SSMS and connecting the SQL Container

Reference 

Popular posts from this blog

VS2017-Build fail-FindDependenciesOfExternallyResolvedReferences

IIS Block IP Setting

VS2017.15.8.4 Error fixed