Docker for Windows

From Wildsong
Jump to navigationJump to search

Refer to the book from Packt, Docker on Windows, Second Edition by Elton Stoneman, who says "My goal is for this to be the definitive book about Docker on Windows, so I've covered everything from a 101 on containers, through modernizing .NET apps with Docker and the security implications of containers, to CI/CD and administration in production. The book ends with a guide to moving forward with Docker in your own projects."

https://docs.docker.com/docker-for-windows/


Workflow anticipated

  • Develop on Windows 10
  • Move container to Windows Server 2019

Windows 10

Download and install Docker Desktop for Windows.

Try Docker Desktop for Windows

I tried using the Windows version but there are very few images for it so I am using the Linux version (which is the default on install.)

Docker Desktop runs as a service (lower right corner look for the Docker whale)

First things first in a bash shell I try:

winpty docker run -it --rm hello-world

and it works. Note in these commands you only need the "winpty" prefix if you are running Git bash, if you use CMD or PowerShell leave it off. Awesome progress! Woot!

Next step is to run a Python flask service inside a Docker on my desktop. Just to test that. It will end up buried inside https://github.com/wildsong/ContourBuilderDocker

PYTHON FLASK:

NODE: I originally started with Node, setting up my sample here: https://github.com/brian32768/docker-node-service and I will put notes on that in the README.md file there.

Note on running Linux containers on Windows

If you run a Linux container on a Windows machine you will be running a Linux virtual machine to host the Docker container(s) and that will be a heavier load on the server and also have resource limits (in particular, RAM will be capped by the Linux VM).

You can switch anytime if you for example want to run a test locally before deploying to a Linux server. In Kitematic it's an option "Switch to Linux containers..."

Windows Server 2019

Windows Server 2019 includes a license for Docker Enterprise. Cool.

Examples I see use "require" to load a particular version (typically 18.03) but are a year old. I wonder what the current version is?

I prefer these instructions, direct from Docker.com: https://docs.docker.com/install/windows/docker-ee/

  1. Remote into Windows Server
  2. Start PowerShell as administrator
  3. In PowerShell run these commands.
Install-Module -Name DockerMsFtProvider -Repository -Force
Install-Package Docker -ProviderName DockerMsftProvider -Force

The first command adds the repository to the installer and the second actually does the package installation. The second command takes a long time, it does a big download. Finally, it says

WARNING: A restart is required to enable the containers feature. Please restart your machine.  

Name                           Version          Source           Summary
----                           -------          ------           -------
Docker                         19.03.2          DockerDefault    Contains Docker EE for use with Windows Server.

Oh great, restart required. I scheduled it for tonight. At least I have some idea there is actually a Docker Engine available though. Will schedule the restart for tonight. Half the reason I am doing this is the hope that I will be able to stop and start containers whenever I need to without the pain of server restarts.

I will be continuing this section at 5:15pm after the restart... Back up to the Windows 10 section now.