Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Deploying applications to Windows Server 2016 and Windows Containers

1,779 views

Published on

Deploying applications to Windows Server 2016 and Windows Containers.

Delivered at NDC London 2017 on 20th January.

Sponsored by Katacoda.com, interactive learning platform for Docker and Cloud Native platforms.

Published in: Technology
  • Login to see the comments

Deploying applications to Windows Server 2016 and Windows Containers

  1. 1. Deploying Applications to Windows Containers and Windows Server 2016 @Ben_Hall Ben@BenHall.me.uk OcelotUproar.com / Katacoda.com
  2. 2. Deploying Applications to Windows Containers and Windows Server 2016 @Ben_Hall Ben@BenHall.me.uk OcelotUproar.com / Katacoda.com
  3. 3. @Ben_Hall / Blog.BenHall.me.uk Docker London Organiser Microsoft MVP in Cloud / Datacentre Management Software Development Studio WHOAMI?
  4. 4. Learn via Interactive Browser-Based Labs Katacoda.com
  5. 5. Agenda • Windows Server 2016 • Building and deploying Windows Containers • Differences to Linux • Hyper-V Containers • Docker API / Kubernetes / Swarm • Future
  6. 6. http://www.infoworld.com/article/3072929/linux/containers-101-linux-containers-and-docker-explained.html
  7. 7. Containers are not Virtual Machines Think of Docker more as a process management
  8. 8. Docker - An open platform for distributed applications for developers and sysadmins.
  9. 9. Batteries included but removable
  10. 10. Three Key Concepts • Docker Containers – Running Processes • Docker Images – “Layered Zip Files” • Docker Registry – Where Images are stored
  11. 11. http://windows-wallpapers.net/wp-content/uploads/images/1c/windows-98.png
  12. 12. Windows Server Core Windows Nano Windows Containers Windows Hyper-V Containers
  13. 13. Windows Containers Windows Kernel Windows Server 2016 SQL Server MSMQ IIS / ASP.NET Docker Engine
  14. 14. Windows Hyper-V Containers Windows Kernel Windows Server 2016 SQL Server MSMQ IIS / ASP.NET Windows Kernel Windows Utility VM Hyper-V Docker Engine
  15. 15. Windows Server Core • Nearly Win32 Compatible • Same behaviour of Windows • Install all of the same tooling
  16. 16. Windows Nano • Stripped down • Smallest footprint • 1/20th the size of Windows Server Core • Only essential components – Hyper-V, Clustering, Networking, Storage, .Net, Core CLR
  17. 17. Windows Server Core => Ubuntu Linux Windows Nano => Alpine Linux Windows Server Core => Legacy Apps? Windows Nano => Modern Apps?
  18. 18. Installing Windows Containers
  19. 19. > Install-Module -Name DockerMsftProvider -Repository PSGallery -Force > Install-Package -Name docker -ProviderName DockerMsftProvider > Restart-Computer -Force
  20. 20. Layered Zip File
  21. 21. Windows Linux Subsystem • Completely unrelated • Maybe not in the future…
  22. 22. What is a Windows Docker Image?
  23. 23. PS C:> docker images REPOSITORY TAG IMAGE ID CREATED windowsservercore 10.0.10586.0 6801d964fda5 2 weeks ago windowsservercore latest 6801d964fda5 2 weeks ago nanoserver 10.0.10586.0 8572198a60f1 2 weeks ago nanoserver latest 8572198a60f1 2 weeks ago
  24. 24. PS C:> docker run -it windowsservercore cmd Thank you to https://msdn.microsoft.com/en-
  25. 25. SSMS
  26. 26. Building Windows based Docker Images
  27. 27. Latest Tag • Official images have a convention of :latest • Using :latest can introduces problems • Use CI build number / Semver
  28. 28. Dockerfile
  29. 29. > type Dockerfile FROM microsoft/windowsservercore:10.0.14393.693 RUN powershell.exe Install-WindowsFeature web-server > docker build –t iis .
  30. 30. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command“]
  31. 31. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command"] RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install- WindowsFeature Web-Asp-Net45
  32. 32. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command"] RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install- WindowsFeature Web-Asp-Net45 RUN Remove-Website -Name 'Default Web Site'; mkdir c:NerdDinner; New-Website -Name 'nerd-dinner' -Port 80 -PhysicalPath 'c:NerdDinner' -ApplicationPool '.NET v4.5‘
  33. 33. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command"] RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install- WindowsFeature Web-Asp-Net45 RUN Remove-Website -Name 'Default Web Site'; mkdir c:NerdDinner; New-Website -Name 'nerd-dinner' -Port 80 -PhysicalPath 'c:NerdDinner' -ApplicationPool '.NET v4.5‘ EXPOSE 80
  34. 34. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command"] RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install- WindowsFeature Web-Asp-Net45 RUN Remove-Website -Name 'Default Web Site'; mkdir c:NerdDinner; New-Website -Name 'nerd-dinner' -Port 80 -PhysicalPath 'c:NerdDinner' -ApplicationPool '.NET v4.5‘ EXPOSE 80 COPY NerdDinner c:NerdDinner
  35. 35. PS C:> docker build –t nerddinner .
  36. 36. PS C:> docker run -d -p 80:80 nerddinner
  37. 37. PS C:> docker build –t nerddinner .
  38. 38. PS C:> docker run -d -p 80:80 nerddinner
  39. 39. PS C:> docker run -d -p 80:80 nerddinner
  40. 40. PS C:> docker run -d -p 80:80 --isolation=hyperv nerddinner
  41. 41. Immutable Disposable Container Pattern
  42. 42. Windows Updates?
  43. 43. Persisting Data – Data Volumes > docker run –v <host-dir>:<container-dir> image -v C:source:C:dest -v C:container-shareconfig.ini -v d: -v C:nerddinnerlogs:C:inetpublogsLogFiles
  44. 44. Limit CPU Shares > docker run -it --cpu-shares 2 --name dockerdemo windowsservercore cmd
  45. 45. Powershell API PS C:> Get-ContainerImage Name Publisher Version IsOSImage ---- --------- ------- --------- NanoServer CN=Microsoft 10.0.10584.1000 True WindowsServerCore CN=Microsoft 10.0.10584.1000 True
  46. 46. PS C:> New-Container -ContainerImageName WindowsServerCore -Name demo - ContainerComputerName demo Name State Uptime ParentImageName ---- ----- ------ --------------- demo Off 00:00:00 WindowsServerCore
  47. 47. SQL Server Dependency
  48. 48. docker run --name nerddinnerdb -d -p 1433:1433 -e sa_password=password -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express
  49. 49. PS C:>docker logs nerddinnerdb
  50. 50. docker run --name nerddinnerdb -d -p 1433:1433 -e sa_password=p@sSw0rd1sl0ngY0 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express
  51. 51. Docker Compose
  52. 52. > cinst –y docker-compose
  53. 53. > type docker-compose.yml version: '2.1' networks: default: external: name: nat services: nerddinnerdb: image: microsoft/mssql-server-windows-express:2016-sp1-windowsservercore-10.0.14393.447 ports: - "1433:1433" environment: sa_password: "p@sSw0rd1sl0ngY0" ACCEPT_EULA: "Y" nerddinnerweb: build: . ports: - "80:80" depends_on: - nerddinnerdb > docker-compose up -d
  54. 54. > type Dockerfile.windows FROM microsoft/dotnet:1.0.0-preview2.1-nanoserver-sdk SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] RUN New-Item -Path MusicStoresamplesMusicStore.Standalone -Type Directory WORKDIR MusicStore ADD samples/MusicStore.Standalone/project.json samples/MusicStore.Standalone/project.json ADD NuGet.config . RUN dotnet restore --no-cache .samplesMusicStore.Standalone ADD samples samples RUN dotnet build .samplesMusicStore.Standalone EXPOSE 5000 ENV ASPNETCORE_URLS http://0.0.0.0:5000 CMD dotnet run -p .samplesMusicStore.Standalone https://github.com/taylorb-microsoft/MusicStore
  55. 55. > type docker-compose.yml version: '2' services: db: image: microsoft/mssql-server-2016-express-windows environment: sa_password: "Password1" ports: - "1433:1433" # for debug. Remove this for production web: build: context: . dockerfile: Dockerfile.windows environment: - "Data:DefaultConnection:ConnectionString=Server=db,1433;Database=MusicStore;User Id=sa;Password=Password1;MultipleActiveResultSets=True" depends_on: - "db" ports: - "5000:5000" networks: default: external: name: nat > docker-compose up –d --build https://github.com/taylorb-microsoft/MusicStore
  56. 56. > docker tag nerddinner benhall/nerddinner:v2.0 > docker push benhall/nerddinner:v2.0
  57. 57. CI/CD Pipeline Git Push Gitlab Starts Build docker build Gitlab Start Release docker push Docker Compose Pull/Up docker pull
  58. 58. > cat .gitlab-ci.yml variables: IMAGE_NAME: registry.katacoda.com:4567/root/front-end TAG: $CI_BUILD_ID stages: - build - push build_production: stage: build script: - docker build -t $IMAGE_NAME:$TAG . only: - master push_production: stage: build script: - docker push $IMAGE_NAME:$TAG only: - master
  59. 59. How is this different to Linux?
  60. 60. Kernel Virtualisation
  61. 61. http://www.slideshare.net/Docker/windows-server-and-docker-the-internals-behind-bringing- docker-and-containers-to-windows-by-taylor-brown-and-john-starks
  62. 62. http://www.slideshare.net/Docker/windows-server-and-docker-the-internals-behind-bringing- docker-and-containers-to-windows-by-taylor-brown-and-john-starks
  63. 63. Windows Hyper-V Isolation
  64. 64. Windows Hyper-V Isolation • Problem: Shared Kernel • Solution: Super lightweight virtual machines • Intel Clear Containers • Ubuntu LXD • IBM are working on something
  65. 65. PS C:> docker run -it -p 80:80 --isolation=hyperv app cmd 1) Windows starts 'Utility VM‘ and freezes state 2) Forks VM state, brings up a fresh second VM 3) Launches container on VM
  66. 66. Properties of Windows Utility VM • Invisible to Docker and containers • All writes are degraded • Separate Kernel to host • SMB file share to access host data • In the future used for Linux containers?
  67. 67. What about developers?
  68. 68. Install Containers Support on Windows 10 > Enable-WindowsOptionalFeature -Online -FeatureName containers -All > Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All > Restart-Computer -Force > Invoke-WebRequest "https://test.docker.com/builds/Windows/x86_64/docker-1.13.0.zip" -OutFile "$env:TEMPdocker-1.13.0-rc4.zip" -UseBasicParsing > Expand-Archive -Path "$env:TEMPdocker-1.13.0.zip" -DestinationPath $env:ProgramFiles > dockerd --register-service > Start-Service Docker
  69. 69. Docker for Windows https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html
  70. 70. Docker for Windows https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html
  71. 71. Docker for Windows https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html
  72. 72. Running Containers in Production
  73. 73. Swarm
  74. 74. Constraint Scheduler $ docker run -e constraint:ostypelabel==windowscompat windowservercore cmd $ docker run -e constraint:ostypelabel==linuxcompat ubuntu bash
  75. 75. Microsoft, Apprenda, Red Hat https://github.com/kubernetes/kubernetes/issues/22623
  76. 76. Mesosphere DC/OS Powering Azure Container Service
  77. 77. Host Fingerprinting • Constraints based deployment • Container is based on Nano Server, within cluster, deploy to server capable of running Nano Server (ie. Windows Server 2016)Host Fingerprinting
  78. 78. Azure Container Service
  79. 79. The Future?
  80. 80. SQL Server as a Container
  81. 81. Visual Studio as a Container?
  82. 82. Everything as a Container
  83. 83. Deploy Anywhere
  84. 84. www.katacoda.com
  85. 85. Next Steps • Katacoda • Windows Server 2016 on Azure • Windows 10
  86. 86. Thank you! @Ben_Hall Ben@BenHall.me.uk Blog.BenHall.me.uk www.Katacoda.com

×