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.

Docker containers on Windows

153 views

Published on

Docker containers on Windows at the Centric Tech event 2017

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Docker containers on Windows

  1. 1. DockerContainers onWindows
  2. 2. DockerContainers onWindows Maurice de Beijer - @mauricedb
  3. 3. Topics  What is a Container and Docker?  Docker onWindows  Docker andVS2017  Docker and SQL Server © ABL - The Problem Solver 3
  4. 4.  Maurice de Beijer  The Problem Solver  MicrosoftAzure MVP  Freelance developer/instructor  Twitter: @mauricedb  Web: http://www.TheProblemSolver.nl  E-mail: maurice.de.beijer@gmail.com 4
  5. 5. Containers
  6. 6. Virtual Machine vs Container
  7. 7. Linux
  8. 8. Windows
  9. 9. Nano server vs Windows ServerCore  OnWindows Docker containers can either run Nano Server or Windows Server Core  The microsoft/nanoserver  The image is 1.08GB  microsoft/windowsservercore  The image is 10.3GB 
  10. 10. Container runtimes Windows Server Containers docker run --isolation=process  Uses a shared kernel  Process & namespace isolation  Trusted code only  Windows Server 2016 only Hyper-V Isolation docker run --isolation=hyperv  Kernel is not shared.  Optimized virtual machine  Execute untrusted code  Windows 10 or server 2016
  11. 11. Simple Dockerfile FROM microsoft/aspnetcore-build:2.0 WORKDIR /app EXPOSE 80 COPY MyWebApp . ENTRYPOINT ["dotnet", "run", "--no-launch-profile"]
  12. 12. The problem  Using source code in production  4.64MB the initial application  Optionally:  RUN dotnet build  ENTRYPOINT ["dotnet", " MyWebApp.dll"]  Large image with complete SDK and NuGet packages  2.75GB on Windows  1.86GB on Linux  Based on 100MB Debian
  13. 13. The solution  Only release binaries in container image  Just 2.72MB for the initial application   Much smaller image  1.25GB onWindows  283MB on Linux  Based on 100MB Debian  Alpine Linux is just 3.97MB 
  14. 14. Multi stage Dockerfile (Builder) # Build and publish source code in image "builder" FROM microsoft/aspnetcore-build:2.0 AS builder WORKDIR /src COPY *.sln ./ COPY MyWebApp/MyWebApp.csproj MyWebApp/ RUN dotnet restore COPY . . WORKDIR /src/MyWebApp RUN dotnet build -c Release -o /app RUN dotnet publish -c Release -o /app
  15. 15. Multi stage Dockerfile (Runtime) # Build actual runtime container image FROM microsoft/aspnetcore:2.0 WORKDIR /app EXPOSE 80 WORKDIR /app COPY --from=builder /app . ENTRYPOINT ["dotnet", " MyWebApp.dll"]
  16. 16. VisualStudio 2017
  17. 17. Docker Compose  A tool for defining and running multi-container Docker applications.  Used byVisual Studio 2017
  18. 18. Docker Compose version: '3' services: dockerdemo: image: dockerdemo build: context: ./DockerDemo dockerfile: Dockerfile
  19. 19. SQLServer 2016 on Docker  Both onWindows and Linux   TheWindows image is 13GB   Based on Windows Server Core  Linux image is 1.4GB  Base on Ubuntu 16
  20. 20. Building a test database # Build a test data image FROM microsoft/mssql-server-windows COPY . . RUN sqlcmd -i CreateAndPopulateDatabase.sql SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop’; $ProgressPreference = 'SilentlyContinue';"] CMD .start -sa_password Password1 -ACCEPT_EULA Y -Verbose
  21. 21. Docker Compose version: '3' services: dockerdemo: image: dockerdemo build: context: ./DockerDemo dockerfile: Dockerfile depends_on: - demodata demodata: image: "demodata:10"
  22. 22. Service name is host name protected override void OnConfiguring( DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( "Server=DemoData;Database=DemoDB;user=sa;password=Password1;"); }
  23. 23. Conclusion © ABL - The Problem Solver 25
  24. 24. Maurice de Beijer @mauricedb maurice.de.beijer @gmail.com © ABL - The Problem Solver 26

×