How to Run Docker Linux Containers on Windows Server 2016 Build 14393 - docker

I'm in a situation where:
I have no choice of server OS (Windows Server 2016 Build 14393).
And no choice of container OS (I need Linux Containers).
And I don't need Docker EE (Enterprise), CE (Desktop Edition) will do.

The easiest way to get Linux containers without hacky workarounds is to download Docker Community Edition 2.0.0.3 2019-02-15
Link: https://download.docker.com/win/stable/31259/Docker%20for%20Windows%20Installer.exe
Page with all versions: https://docs.docker.com/docker-for-windows/release-notes/
Simply download/copy the file to the Windows Server 2016 machine and run it.
It can also run offline for air gapped systems.
Uncheck the "Use Windows containers" during setup. Unchecked by default.
You will get a message after installing saying that windows so and so is deprecated. Click OK.
Log out and log back in.
If you hadn't installed Hyper-V it'll prompt you to do it automatically. Allow it, let it finish and restart. You're good to go now.
I've tested this by running several Linux containers, it works fine. If I'm missing something do share for the benefit of others. The downside is you cannot update to a later version of Docker.
Update:
Disclaimers:
This can help you avoid the hardware limitations and complexities of using LCOW with Docker-EE for Windows.
It is more recent than the latest official version of LCOW available.
This won't let you run Windows and Linux containers in parallel. You can only run one or the other.
This also won't start docker automatically at startup (not until you login). To start docker without login you'll need to add Docker Desktop Executable to Windows Task Scheduler and configure it to run on startup whether user is logged in or not. You'll have to provide an account for it (ideally a service account, or an account with a permanent password)

Related

Regarding Docker cross platform compatibility

I want to ask about cross platform compatibilty of Docker ,means if an application is designed to run in a docker container on windows,then can it run on linux or vice -versa?
Docker was create to run on Linux, so the short answer is yes.
The Windows version isn’t stable or recommend (Docker for windows). At least not by now.
“But, Fischer, I use Docker on Windows!” Yes, with WSL (windows subsystem for linux - Some kind of VM), which you can configure to set a memory limit, using the .wsconfig file, and if you look at your Windows Menu you may found a Ubuntu icon, that connects you to the bash.
Docker is largely used for people that develop software, and today many languanges and frameworks use linux, even Microsoft with .Net runs on Linux.
Docker was created to resolve one simple issue: "But it works on my machine." So, it means that a container should run on every platform. At least "it works on my computer" lol
I think the question is regarding a Windows application. If that's the case, a Windows application cannot simply run on Linux containers. For example, .Net Framework doesn't run on Linux. If an application was targeted for Windows, it needs to run on Windows and in that case only a Windows container can run the application.
Docker Desktop can run both: Windows containers and Linux containers, just not at the same time. You have to switch the context so Docker Desktop can target either WSL (for Linux) or HCS (for Windows).

Running Linux Docker Containers on Windows Server 2019

I am exploring docker for one of my company project. In this project I need to run the MemCached on CentOS and I prefer to run this in a docker container. I have successfully able to run this on Windows 10 machine with Docker Community Edition installed. But our project needs Windows Server 2019 in production and I want to run the container of same image (MemCached on CentOS) on windows server 2019. I googled a lot and found a link for running Linux Containers on Windows Server 2019. But as per the above link we are installing docker package in Preview version. I believe that this Preview version I should not use in Production. Is my understanding is correct or not?
Also is there any other stable released way to run Linux containers on Windows Server 2019.
Thanks in advance.
As per the Preview version you can remove the -RequiredVersion preview tag and then install. The process will install Docker Enterprise Edition on Server 2019 and not the CE version as the one for WIN 10.
If the container you want to run is a Linux container then you may face some tough times reason being
The containers(linux) runs on Server 2019 using LCOW way and the LCOW way is an experimental feature.
You said that you want to run container in Production environment and I would say not to use and experimental feature for Production.
Incase you need to run the containers on a server edition of Windows ie Server 2016 or Server 2019 you can go with the Docker CE (ie the same .exe that works on Win 10).
One important point to note is that on server 2016 all the docker versions are not supported.
Docker 2.0.0.31259 is the supported version of Docker on Server 2016.(Latest Docker 2.1.0.3 does not work on server 2016 but it works on Server 2019
Note : I face the same issues as you face ie you want the run the containers on Server 2019. The above are my findings so far. There is no clarity from windows side about how to run docker containers. Please refer to my answer :Here for better understanding
I'm struggling with the same issue for some time, and for me the only working combination of Windows Server and Docker that can effectively run with Linux containers is Windows Server 2019 Standard Edition with an edge release Docker Desktop Community 2.1.3.0 published on 2019-09-16.
The link to read about edge releases and to download them is:
https://docs.docker.com/docker-for-windows/edge-release-notes/
In my case, there was also an issue of nested virtualization, since my Windows Server is installed on VMware machine, and Docker requires Hyper-V inside Windows Server in order to work.
Fixed that issue according to instructions provided here:
https://doitfixit.com/blog/2014/03/06/qhyper-v-components-is-not-runningq-nested-in-vmware-workstation/
as far as my understanding goes, it is experimental feature, however it can be done and works quite OK.
The only requirement is that this feature works on server with hypervisor enabled.
Follow this link: https://www.altaro.com/msp-dojo/linux-containers-windows-server-2019/ for further instructions on how to set it up.

Divio app docker server connection stuck at "installing"

I have a problem with my divio app.
setting up my divio application for the first time, I managed to get a check mark for "docker client", "docker compose", "docker machine" and "virtual box" by installing docker toolbox, however, when trying to install "docker server connection" it seems that Divio app gets stuck at "installing" and nothing actually happens. I left it for hours and nothing happened. What am I getting wrong here? Is it permission issues or something else?
P.S. I'm using windows 7 ultimate 64-bit. Any help is highly appreciated.
Docker, and therefore the Divio local development environment, will run natively on Windows 10 Professional and Enterprise.
On other versions (Windows 10 Home, and earlier versions) it cannot run natively and must be run in a virtual machine.
This is why your installation requires Docker Toolbox and VirtualBox. The best way to get past this is to upgrade to Windows 10 Professional, but that's not an option for everyone.
If the Divio app detects that your system does not support Docker natively, it will do its best to install Docker Toolbox and VirtualBox, but this set-up is more complex and fragile, and as you have seen, setting it up can sometimes fail.
Try these steps:
Quit the Divio application.
Make sure that VirtualBox on your system is fully up-to-date with the latest version. You can download and install it from the VirtualBox website.
Make sure that Docker Toolbox is fully up-to-date with the latest version. You can download and install it from the Docker Toolbox.
Make sure that both applications are able to run if you launch them manually.
Ensure that you are running as an administrator user.
Check that virtualisation is enabled in your PC's BIOS.
Finally, try again with the Divio app.

Does docker have a windows container to build windows applications on?

I am on a mac but want to build my application on a windows image. Is this possible with docker? If so what image do I need to use?
The reason I need to build the application on windows is for the code signing and binary building of electron. If this is not possible please let me know.
Since docker is not meant to be a UI for users (though it can be); images for Windows 7, 8, 10, et al are not available. However, Windows Server Core IS available via the Docker Hub.
If you simply need a x86 Win environment to build the application that should do the trick. If you need a full GUI, go Virtual Box or other virtualization tech. Docker containers are meant for single process isolation, ever see windows run only 1 process?
Hope this helps!
Update: It IS possible to run GUI applications via Docker; at least on a Linux host. http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
Update2: It is now possible to run Windows applications (CLI or GUI) via Docker: here and here has information regarding the process.

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?
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.
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
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".
The below worked on Windows Server 2016 build 14393.693 (January 2017) without hacky workarounds.
It may work on higher/lower builds but I tried to replicate on a recently updated version of Windows Server 2016 and it failed spectacularly! Feels like this hole had to be patched!
Download Docker Community Edition 2.0.0.3 2019-02-15
Link: https://download.docker.com/win/stable/31259/Docker%20for%20Windows%20Installer.exe
Page with all versions: https://docs.docker.com/docker-for-windows/release-notes/
Simply download/copy the file to the Windows Server 2016 machine and run it.
It can also run offline for air-gapped systems.
Uncheck the "Use Windows containers" during setup. Unchecked by default.
You will get a message after installing saying that windows so and so is deprecated. Click OK. enter image description here
Log out and log back in.
If you hadn't installed Hyper-V it'll prompt you to do it automatically. Allow it, let it finish and restart. You're good to go now. You may need to restart again if it fails to switch to Linux.
I've tested this by running several Linux containers, it works fine. If I'm missing something do share for the benefit of others. The downside is you cannot update to a later version of Docker.
Simply download and install Docker on Windows Server 2016 https://www.docker.com/docker-windows
If you run Windows Server 2016 as a VM using Hyper-V make sure to check this MS doc https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization

Resources