Docker for Windows: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
Refer to the book from Packt, ''Docker on Windows, Second Edition''
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/
https://docs.docker.com/docker-for-windows/
Line 11: Line 11:
== Windows 10 ==
== Windows 10 ==


Download and install Docker Desktop for Windows. (Be prepared; this requires a logout and a reboot!)
Download and install Docker Desktop for Windows.


Try [https://hub.docker.com/?overlay=onboarding Docker Desktop for Windows]
Try [https://hub.docker.com/?overlay=onboarding Docker Desktop for Windows]
Tick the box "Use Windows containers instead of Linux containers (this can be changed after installation)".


This installs Kitematic, which runs as a service (lower right corner look for the Docker whale)
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.)


In Kitematic, turn on experimental features under Settings->Daemon. This worksaround a glitch, which manifests on builds as
Docker Desktop runs as a service (lower right corner look for the Docker whale)
"no matching manifest for windows/amd64 10.0.18362 in the manifest list entries"


First things first in a bash shell I try
First things first in a bash shell I try:


  winpty docker run -it --rm hello-world
  winpty docker run -it --rm hello-world


and it works, suggesting that I try this
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!


winpty docker run -it mcr.microsoft.com/windows/servercore powershell
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 and you should go look there at the README.md file.


which failed with
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.


C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: manifest
=== Note on running Linux containers on Windows ===
for mcr.microsoft.com/windows/servercore:latest not found: manifest unknown: manifest unknown.
See 'C:/Program Files/Docker/Docker/Resources/bin/docker.exe run --help'.


but adding the 1903 tag worked (after downloading the big bulky (about 2GB) servercore images (it's from Microsoft so it has to be big))  
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).


winpty docker run -it mcr.microsoft.com/windows/servercore:1903 powershell
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..."


=== Note on Linux containers ===
== Windows Server 2019 ==
As I understand it if you run a Linux container on a Windows machine you will really be running a Linux virtual machine to host the Docker containers
 
and that seems to imply it will be a heavier load on the server and probably also have strict resource limits (in particular, RAM will be capped by the
Windows Server 2019 includes a license for Docker Enterprise. Cool.
Linux VM). I am guessing it would have to install WSL (Windows System for Linux) or VirtualBox too.
 
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/
 
# Remote into Windows Server
# Start PowerShell as administrator
# 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.


== Windows Server 2019 ==
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.


Not there yet... come back later today.
I will be continuing this section at 5:15pm after the restart... Back up to the Windows 10 section now.

Latest revision as of 16:27, 11 March 2020

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 and you should go look there at the README.md file.

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.