怎么创建windows container

Windows container有许多优点,部署更容易,更容易与cloud集成,花销更小,等等,更多的信息可以查看

https://channel9.msdn.com/events/build/2015/2-704

下面我主要谈论我在创建windows container遇到的问题。

1. 检查软硬件是否支持

至少是windows10以上支持hyper-V虚拟化,具体查看

https://docs.microsoft.com/zh-cn/virtualization/hyper-v-on-windows/reference/hyper-v-requirements

确保OS的版本尽可能高,host机器的版本应该高于windows image的版本,参看

https://docs.microsoft.com/zh-cn/virtualization/windowscontainers/deploy-containers/base-image-lifecycle

2.安装配置docker

https://docs.microsoft.com/zh-cn/virtualization/windowscontainers/manage-docker/configure-docker-daemon

确保container 已经切换到windows

 怎么创建windows container

3. 获得windows images

https://docs.microsoft.com/zh-cn/virtualization/windowscontainers/manage-containers/container-base-images

docker image pull mcr.microsoft.com/windows:1909

windows image信息如下

https://hub.docker.com/_/microsoft-windows?tab=description

4. 安装SQL进入windows image

https://support.microsoft.com/en-us/help/4047326/support-policy-for-microsoft-sql-server

可以直接获得SQL image,不过如果做具体配置,在windows image安装会更容易

1)  准备dockerfile

参考https://github.com/microsoft/mssql-docker/blob/master/windows/mssql-server-windows-express/dockerfile

2) 安装生成SQL image

docker image build --tag sql2017:v1 --file sql_dockerfile c:\database

3) 检查SQL 状态

https://docs.microsoft.com/zh-cn/sql/tools/sqlcmd-utility?view=sql-server-ver15

实用的命令有:

a)       Get-Service *SQL*  |    Select-Object Name, Status, StartType |   Format-Table -AutoSize

b)       sqlcmd

select @@version;

go

SELECT name, database_id, create_date FROM sys.databases;

SqlCmd -E –Q "RESTORE DATABASE [HzCAT] FROM DISK=‘c:\test\HzCAT.bak‘"

 5. 常规工具安装

1)  redistributable packages for Visual Studio for 2017

https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads

通过dockerfile能够安装成功

From sql2017:v1

Copy vc_redist.x86.exe /

WORKDIR /

Run c:\vc_redist_x86.exe /quiet /install

 

2)  Remote debug

https://docs.microsoft.com/zh-cn/visualstudio/productinfo/2017-redistribution-vs

From sql2017:v1

EXPOSE 4020 4021

Copy VS_RemoteTools.exe /

WORKDIR /

Run VS_RemoteTools.exe /quiet /install

 

 

 

 

 

 

Docker里运行下面命令,vc应该就能调试了

"c:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe" /nostatus /silent /noauth /anyuser /nosecuritywarn

怎么创建windows container

上一篇:关于WPF下用户登录后再启动主窗体的实现方法


下一篇:xlwings和openpyxl的区别