Linux Docker container on Windows Server 2016 - docker
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
Related
"Docker Desktop Starting..." forever on Windows
I have installed Docker Desktop version 4.4.4 and it is not running. It only displays "Docker Desktop Starting ..." but never starts running. I have tried so many ways but didn't solve: Allowing the following files in windows firewall C:\program files\docker\docker\resources\vpnkit.exe, C:\program files\docker\docker\com.docker.service C:\program files\docker\docker\resources\com.docker.proxy.exe Removing 'Docker' and 'Docker Desktop' folders from AppData/Roaming and AppData/Local Uninstalling and reinstalling Docker with different versions including 4.5.1
The main problem is WSL2 does not auto install the kernel when WSL2 installs, yet Docker Desktop expects it already installed. So, fully close & stop Docker as other answers have said, then run this cmd as admin: wsl --update Now open Docker Desktop & it should start up ok.
I've found out another symptom leading to the solution is also related to WSL. On one side, Docker service won't start throwing this error: error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open //./pipe/docker_engine: The system cannot find the file specified. And on the other, WSL is unresponsive. Attempting to run a WSL Distro or WSL command directly on CMD, won't return any output at all. It will just hang in there. So the solution is common to WSL and Docker. I've found in a question regarding the WSL issue, that the LxssManager Windows service is staled (it may show under services.msc as Stopping and all the buttons are greyed out, or I've even seen it Running apparently, but with the Docker and WSL issues above, so something is wrong with it still.) First, we have to get LxssManager PID in order to kill it. Using an elevated shell, we can get it this way: sc queryex LxssManager Having the PID, we can kill the process but beware I wasn't able to kill it using kill or taskkill commands. I was getting the following error: ERROR: The process with PID XXXXX could not be terminated. Reason: Access is denied. To effectively kill the process, do as following: wmic process where ProcessID=XXXXX delete Replace XXXXX with PID, of course. Having done so, start the LxssManager service: net start LxssManager A word of warning: I've noted in some cases this is not enough for unknown (to me) technical reasons even if LxssManager service is shown as Running. Just repeat the above steps! Sometimes it works doing this once, sometimes doing it twice for some reason. TL;DR Kill LxssManager Windows service using wmic+PID. Start LxssManager service. Repeat twice or more if issues persist. Docker and WSL issues are solved.
Here i am using Windows platform, I faced this issue. And to resolve this issue follow the below steps. Just delete the temporary files from the following. C:\Windows\Temp C:\Users{yourAccountName}\AppData\Local\Temp C:\Windows\Prefetch then Uninstall Docker Desktop Restart computer before installing docker, make sure you have Ubuntu WSL(download from Microsoft store) [optional] If you need Terminal Preview(multi-terminal) download from Microsoft Store. Great Terminal Install Docker Desktop Again Thanks
For me, it was a problem with WSL. When I tried: wsl --install -d Ubuntu in a command window, after a few minutes I got error 0x80370114 The fix was to do: Exploit Protection > System Settings > Control Flow Guard turn on restart computer Then reinstall/restart Docker Desktop, and it works! Hope this helps someone else
I was facing same code for for Docker version 4.*. For me it was Visual Studio code, Stopped WSL form Task manager stopped Docker which was showing "Docker desktop is starting" form Task manage stopped Visual Studio code form Task manager Started Docker again These steps placed my Docker in Running state in 30 seconds Hope this helps someone!
Solved this issue with #Alvi answer Docker forever in "Docker is starting.." at Windows task I guess you are using wsl2 features. In that case, open PowerShell or command prompt and type: optionalfeatures.exe scroll down and uncheck Windows Subsystem for Linux apply the changes and restart your computer. After restart follow the previous steps again and check Windows Subsystem for Linux and restart again. Hopefully now your docker will run
My fresh install was experiencing the same symptoms. Also wsl --list showed "no installed distributions". I tried many reinstallations and restarts of Docker and WSL, but eventually found the steps: In Task Manager, kill all processes related to Docker & Docker Desktop Run Docker Desktop as administrator Got it working on on Windows 11 Enterprise.
for me it worked in windows (docker desktop): to uninstall the docker reinstall as administrator don't select the part with wsl
As wrote here, you need to do: wsl --update But after that it doesn't fix my issue until I did restart to my pc.
What worked for me was to log in into the Docker (upper right corner), but when I first clicked on login, it said "exec: "rundll32": executable file not found in %PATH%" - I search and found that I need to check environmental variable in PATH that I have "C:\WINDOWS\system32" there - (and in my case I really had it broken somehow - don't know why, but I missed backslash between Windows and system32). So I fixed to correct path, restarted PC. Then I was able to login. And immediately "Docker Desktop Starting..." was gone.
I use Docker with PyCharm. I ran into this problem when I launched PyCharm and Docker Desktop at about the same time. On my machine Docker Desktop starts automatically when I boot. I can avoid the problem by waiting for Docker Desktop to finish starting. And then start PyCharm.
I was also having the same problem, just a few minutes ago. Platform: Windows 10 Pro - 22H2 - Build 19045.2486 Windows Updates newly installed: KB5022282, KB5020876, KB5012170 What i did was: Activating the Windows Hypervisor Platform And it did solve the problem, atleast for now
In my case it helped me to enable the CPU SVM (Support Vector Machine) function in my BIOS settings. Also, if you have this feature disabled, you will not be able to use Virtual Box either. SVM in BIOS
got to services and stop Docker desktop service and start again reopen Docker desktop it will work
wsl -v if it show version then linx is install search windows programer feature in your laptop enable virtulization wsl --set-default-version 2 restart laptop and then start docker and wait for 2 minutes your docker will start working
I am running windows 11, visual studio 2023 and had this issue. First, open a command prompt and type wsl.exe --list --online Then enter following wsl.exe --install Ubuntu-20.04 Then type in the prompt sudo apt update to update the distribution. Lastly, start up Docker desktop and log in (you can register at their site). That fixed Docker on my pc.
Docker for windows missing quick start terminal
I installed the latest version of Docker for windows in my windows 10 machine. It seems the new Docker Desktop toolbox doesn't contain the Quick start terminal. Every documentation says to check the quick start terminal option at the time of installation. I dont see any option to check that option with the latest Docker toolbox. Is there any way we could install Quick start terminal for windows. Or are there any other alternate to the QS terminal. My objective is to build, tag and push / pull docker images to a gitlab registry. Powershell, command promt doesn't work because its a windows machine.
with the new Docker-for-desktop versions there's no need for the added toolbox as marked here Legacy desktop solution. Docker Toolbox is for older Mac and Windows systems that do not meet the requirements of Docker for Mac and Docker for Windows. We recommend updating to the newer applications, if possible. You can just open any typical terminal in your OS of choice and use the docker cli if you can't remember the exact usage try docker --help 😉
System.InvalidOperationException: Failed to deploy distro docker-desktop to <localpath>: exit code: -1
I am trying to run docker Desktop in my windows 10 Local. have installed it successfully but while running it I am getting the below error. System.InvalidOperationException: Failed to deploy distro docker-desktop to <localpath>: exit code: -1 stdout: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. I think it is saying some windows services need to be enabled, but I don't know which service has to be enabled could someone please help me with this concern? docker version C:\Users\lenova>docker --version Docker version 20.10.2, build 2291f61
Uninstall Docker. Uncheck Containers, Hyper-V, Windows Subsystem for Linux in Windows features Restart the system Install Docker Desktop Restart System Start Docker Desktop
Right click on docker icon, run as administrator (if you have administrator rights on your computer). It solved the problem for me.
Try delete %USERPROFILE%/.wslconfig. If it helps then you can try to modify it so that it work. As for me I deleted the file, because on my workstation docker didn't want to work with it
Almost sure, that the accepted answer will work. However, it won't be an option, if you utilize WSL for other purposes as well. In that case, you may have several configurations/apps in WSL and just reinstalling or deleting your configuration will probably be a bad solution. Furthermore: WSL is not the issue for this error! It is created by Docker engine configuration which will kill the WSL service (LxxsManager). This may happen because of changed configuration (by you) or because of a Docker update, maybe also because of Windows updates You can find a detailed discussion about this issue on Docker's GitHub Issues. I personally experienced this problem after installing updates on Windows while running Docker v3.5.2. And again, reinstalling/killing WSL is not an option for me! So I tried to kill all services (Docker and WSL) and update Docker. Unfortunately that did not work in first place, since LxxsManager was in some weird state and I could not even kill it any more (even a kill command as admin with force switch did not do it's job!)... So here is my solution to fix that problem: Remove Docker from autostart Restart Windows (Yippiee: WSL works again! 🥰) Install a new version of Docker (in my case v.4.2.0) Restart Windows again (probably not necessary, but for me it was because Docker engine did not start before a Windows restart) Start Docker (Yippiee: Docker works again! ☺️) Note: Since I did not change Docker configuration, I installed an update. If you changed configuration options resulting in that crash, your solution may be different. Literally, instead of updating Docker (step 3) you would probably roll back your Docker configuration changes instead.
The quality of Docker for Windows is very bad. I catch these dangerous very often. Check list: (1) Use this tool https://www.nirsoft.net/utils/regscanner.html . Search docker, delete all. (2) Remove WSL sub system, Hyper-V, then restart (3). Create file foo.reg has content Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3] "AppFullPath"="C:\\Windows\\System32\\wsl.exe" "PermittedLspCategories"=dword:80000000 run. (4) Uninstall Docker (5) Run cmd type ... . Delete folder .docker Delete Docker folder in Program Files (6) delete (7) Install latest version of Docker. (8) Re-install feature WSL for Windows. Install Ubuntu from Windows store (9) Re-install Docker (as Administrator) (10) Run Docker as Administrator .
In my case, I was getting a similar error. This was happening because Docker desktop didn't have permissions to access the path C:\Users\Adithya\AppData\Local\Docker\wsl\distro. This started happening after I switched to WSL2 backend. The solution was to kill all docker process. Next, Run Docker Desktop as Administrator. System.InvalidOperationException: Failed to deploy distro docker-desktop to C:\Users\Adithya\AppData\Local\Docker\wsl\distro: exit code: -1 stdout: The operation timed out because a response was not received from the virtual machine or container.
run as administrator , and you switch the container to windows by clicking the icon bar in the right corner taskbar and choose switch to windows container https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10-linux
If you don't need to run Linux and Windows containers side-by-side, an option is to turn off the WSL and use Hyper-v instead. This should work fine.
I had to exit Private Internet Access (PIA) VPN to get docker to work on my system. Not sure why.
I had the PgAdmin 4 app running, and when I closed it and tried starting Docker Desktop again it booted normally. Not sure if there is a link, but an easy solution to try.
This worked for me: https://github.com/MicrosoftDocs/WSL/issues/547#issuecomment-873540236 Copy below snippet: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3] "AppFullPath"="C:\\Windows\\System32\\wsl.exe" "PermittedLspCategories"=dword:80000000 Save it as a file wsl.reg Execute the file to update the registry Launch Ubuntu again Issue resolved
In my case, the issue was caused by Acrylic DNS server. Anything that holds port 53, would be a problem. Interesting that it all worked fine for a few days after installation, maybe because I did not reboot the laptop all that time, only used the deep hibernation. So it was hard to guess what could break the docker setup, I was sure that it was because of the recently installed windows or docker updates.
Restarting wsl worked for me. Run the following wsl --shutdown, wait for it to shutdown wsl, wait for it to start Start Docker Desktop after this.
On Windows 10: Open Services Right click on LXSSMANAGER -> Restart Close wsl using cmd with following command: wsl --shutdown Execute following start wsl again: wsl
I solved by the following steps: Uninstall Docker and WSL 2 kernel. Uncheck Containers, Hyper-V, Windows Subsystem for Linux in Windows features Restart the system Install Docker Desktop Restart System Start Docker Desktop
The problem is in WSL as it becomes unresponsive and returns a service error if you try the following command in PowerShell: wsl -l -v I believe the process can be simplified a bit more with: Uncheck Windows Subsystem for Linux in Windows Features Reboot Turn the feature back on Re-apply the WSL2 update Reboot No need to uninstall/reinstall Docker Desktop. This got me back up and running with Windows 10 Home (which requires WSL2) and Docker Desktop 2.4.0
How to Run Docker Linux Containers on Windows Server 2016 Build 14393
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)
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.