3

I want to run a Linux Docker-Container on Windows Server-2022 without to login to windows and starting Docker Desktop. I managed to create a Windows-Service for dockerd. But there I can not create Linux-Containers. Errormessage:

docker: image operating system "linux" cannot be used on this platform.

As docker runs as a Windows-Service, I can not change the Engine with dockerCLI, or I don't no how. This solution changes the Engine for my Windows-User but not for the Windows-Service. On my Windows-User I can run Linux-Containers without a Problem.

My Question is: How can I run a Linux Docker-Container permanently on Windows Server 2022 without the need to login on Windows?

CaptainInler
  • 157
  • 1
  • 9
  • That's not exactly a programming question. You aren't asking how to `run a Linux Docker-Container permanently ... without the need to login on Windows` you're asking how to use Linux Docker containers in production. Which isn't supported but is *still* possible. The article you linked to shows you can use `dockerd --register-service` to register Docker as a service. Linux Containers run on WSL2 so that has to be installed. That's still mainly for testing though – Panagiotis Kanavos Dec 02 '22 at 11:32
  • 1
    The important part is WSL2, not Docker itself. You can already run Linux in a VM and run Docker inside it. The only reason to use Docker directly is because you want to run containers on WSL2. So the real question is how to keep WSL running without anyone logged in. Once that is done, you can install Docker inside WSL2 if you want – Panagiotis Kanavos Dec 02 '22 at 11:35
  • @PanagiotisKanavos Thanks for your reply and for pointing me to the real question: "how to keep WSL running without anyone logged in". That makes a lot of sense. Something I don't understand is, why can docker be registered as a service but not used while not logged in? This makes sense on Windows 11 but on a Server-Edition where usual nobody is logged in..? – CaptainInler Dec 02 '22 at 14:25
  • Why do you want to do this in the first place? Why not use a Hyper-V VM to run the Docker host? "Not supported but works" means the WSL team isn't actively trying to use WSL as a service. There's no guarantee it will stay up, nothing that will restart it if it crashes. – Panagiotis Kanavos Dec 02 '22 at 14:33
  • @PanagiotisKanavos I have to use a Windows Server (not my decision) and I need to use this software where a docker image just works great but can not (easy) installed on windows.. Hyper-V means that I have to install a Linux-VM first (on virtualbox?) to install there docker? – CaptainInler Dec 02 '22 at 14:55
  • Hyper-V is the native virtualization of Windows Server, equivalent to VMWare. It goes deeper than VirtualBox and thus faster. It can even run on bare metal. It's the same technology that enables WSL and Docker Desktop, and is a lot faster than VirtualBox. [This Docker docs page](https://docker-docs.netlify.app/machine/drivers/hyper-v/) shows how to tell Docker to use Hyper-V to run the docker host instead of WSL. Before WSL, Docker itself used a Hyper-V VM. Like VMWare (and some VirtualBox bundles) it offers monitoring, clustering, – Panagiotis Kanavos Dec 02 '22 at 15:12
  • @PanagiotisKanavos to use docker on Hyper-V as mentioned in your link, docker-machine has to be installed. This is not under development since 2019 and now archived.. – CaptainInler Dec 06 '22 at 12:41
  • Not at all. You can install any guest OS or distribution you want in a VM, then install Docker or any other application in the way appropriate for that OS. You can install a full Ubuntu, or you can find something that only installs Docker itself. – Panagiotis Kanavos Dec 06 '22 at 12:43

1 Answers1

2

You can achieve this by installing WSL2 on the machine and run docker through WSL2

https://techcommunity.microsoft.com/t5/itops-talk-blog/using-wsl-2-on-windows-server-2022-to-run-linux-containers/ba-p/3624745

abo
  • 86
  • 3