Docker for Windows: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) |
||
Line 47: | Line 47: | ||
PS C:\> | PS C:\> | ||
Awesome progress! Woot! I am going to jump down to Windows Server section now to run the | Awesome progress! Woot! I am going to jump down to Windows Server section now to run the installation steps there, | ||
because if I can't run Docker on Server then it's useless to me. | because if I can't run Docker on Server then it's useless to me. | ||
OKAY, I am back. Next step is to run a node service inside a Docker on my desktop. "Hello, world" was fun but it's time to do something useful. I am setting up my sample here: https://github.com/brian32768/docker-node-service | |||
=== Note on running Linux containers on Windows === | === Note on running Linux containers on Windows === |
Revision as of 19:15, 8 October 2019
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. (Be prepared; this requires a logout and a reboot!)
Try 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)
In Kitematic, turn on experimental features under Settings->Daemon. This worksaround a glitch, which manifests on builds as "no matching manifest for windows/amd64 10.0.18362 in the manifest list entries"
First things first in a bash shell I try
winpty docker run -it --rm hello-world
and it works, suggesting that I try this
winpty docker run -it mcr.microsoft.com/windows/servercore powershell
which failed with
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: manifest 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))
winpty docker run -it mcr.microsoft.com/windows/servercore:1903 powershell . . Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\>
Awesome progress! Woot! I am going to jump down to Windows Server section now to run the installation steps there, because if I can't run Docker on Server then it's useless to me.
OKAY, I am back. Next step is to run a node service inside a Docker on my desktop. "Hello, world" was fun but it's time to do something useful. I am setting up my sample here: https://github.com/brian32768/docker-node-service
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/
- 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.
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.