Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Docker container on Windows Server 2016

What is the way to run Linux docker container on Windows Server 2016? With Docker for Windows it easy to do in Windows 10. Is the only way to install Docker Toolbox and ignore the build-in containers feature all together?

like image 794
Natalia Avatar asked Dec 06 '16 12:12

Natalia


3 Answers

It is possible to use Linux containers on W2016. It's a bit hacky though. User "Algore" described it here but I've copied it into this answer, of course.

  • Download "Docker for Windows": https://docs.docker.com/docker-for-windows/

  • Install "Docker for Windows" on Windows 10 Pro.

  • Copy C:\Program Files\Docker from the Windows 10 machine to C:\Program Files on your Server 2016 box.

  • On the W2016 box run install-windowsfeature hyper-v,containers

  • Copy these registry entries to a file and import them on your Server 2016 box (reg import):

---START---
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.]

[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker]

[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker\1.0]
"AppPath"="\"C:\Program Files\Docker\Docker\Docker for Windows.exe\""
"BinPath"="\"C:\Program Files\Docker\Docker\resources\bin\""

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\DockerService]
"EventMessageFile"=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,\ 00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,\ 4e,00,45,00,54,00,5c,00,46,00,72,00,61,00,6d,00,65,00,77,00,6f,00,72,00,6b,\ 00,36,00,34,00,5c,00,76,00,34,00,2e,00,30,00,2e,00,33,00,30,00,33,00,31,00,\ 39,00,5c,00,45,00,76,00,65,00,6e,00,74,00,4c,00,6f,00,67,00,4d,00,65,00,73,\ 00,73,00,61,00,67,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\com.docker.service] "Type"=dword:00000010 "Start"=dword:00000002 "ErrorControl"=dword:00000000 "ImagePath"=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\ 6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,44,00,6f,00,63,00,6b,00,65,\ 00,72,00,5c,00,44,00,6f,00,63,00,6b,00,65,00,72,00,5c,00,63,00,6f,00,6d,00,\ 2e,00,64,00,6f,00,63,00,6b,00,65,00,72,00,2e,00,73,00,65,00,72,00,76,00,69,\ 00,63,00,65,00,22,00,00,00
"DisplayName"="Docker for Windows Service"
"ObjectName"="LocalSystem"
"Description"="Run Docker for Windows backend service"
---END---

You can add an entry to currentversion\run or a scheduled job if you want docker for windows.exe to start up automatically.

  • Restart the computer and run the PowerShell script C:\Program Files\Docker\Docker\Resources\mobylinuxvm.ps1 -Create

Look into this ps1 file and notice that you can set various options. Please refer to these websites:

https://docker-saigon.github.io/post/Docker-Beta/
https://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/

  • Make sure the docker service com.docker.service (start-service com.docker.service) is running before you start C:\Program Files\Docker\Docker for Windows.exe

If you are running on server core and don't have the tray icon, click "change privacy settings" when the notification comes up after it starts to get to settings (or modify the json in programdata)

If you run into issues when trying things and rebuilding, check out the C:\Program Files\Docker\Docker\Resources\forceremovedocker.ps1 file for locations to delete settings such as in C:\programdata. I would advise against running the script as it deletes all docker related things. Just use pieces of it.

like image 98
Boggin Avatar answered Oct 08 '22 01:10

Boggin


According to this from Stefan Scherer it is possible to run Linux containers on Server 2016. The instructions are:

Create a Linux Docker machine in Hyper-V

If you want to try out multi architecture you also use docker-machine to create a Linux Docker Engine running in Hyper-V. I have prepared a script that will set up everything as there are some known issues.

C:\vagrant\scripts\create-hyperv-linux-docker-machine.ps1

This PowerShell script creates a Docker machine and updates Docker Engine to the latest so that the Windows Docker client is able to communicate with the Linux Docker Engine.

Use the Linux Docker machine

Open a PowerShell terminal as an administrator and select the Linux Docker machine with

docker-machine env --shell powershell | iex

Now run your first busybox container with

docker run -it busybox uname -a
like image 31
Dave Avatar answered Oct 08 '22 01:10

Dave


Unfortunately, right now it is not possible to easily install the "Docker for Windows" tool. This installer provides a thin VM called MobyLinux which allows running of Linux containers on Windows Server 2016. You can find a hacky install attempt (which I have not tried) on the Docker forums.

For reference there is a good discussion about what is going on behind the scenes with "Docker for Windows".

like image 23
William Denman Avatar answered Oct 08 '22 00:10

William Denman