1. Home
  2. Windows Tips
  3. How to run linux docker containers on windows server

How to run Linux Docker containers on Windows Server

Docker for Windows provided by Microsoft and installable via PowerShell is nice, and it allows Windows Server users to download and deploy Windows containers. However, this version of Docker is limited, and you cannot run Linux containers, only Windows ones.

While a good chunk of high-level server applications is Linux-only. This means if you want to deploy something like PhotoPrism, Postgres, Httpd, Memcached, etc. on a Windows Server, you will need Linux container support in Docker.

In this guide, we’ll show you how to run Linux containers on your Windows server system with Docker Desktop for Windows on Windows Server.

How to download Docker Desktop for Windows

Docker Desktop for Windows differs from Docker provided by Windows in PowerShell. Docker Desktop allows users to run both Linux and Windows containers and comes with a proper GUI.

To get your hands on Docker Desktop for Windows, you will need to create an account on Dockerhub. Go to the site and in the “Get Started Today for Free” box, enter a username, email address, and password to sign up.

Once you’ve signed up, verify your email account, and log in. Then, access the Dockerhub. When you do, you’ll see a message to “Download the desktop application.” Find the “Download for Windows” button, and click it to download the Docker Desktop for Windows installer EXE.

How to set up Docker Desktop for Windows on Windows Server

Docker Desktop for Windows works with either WSL 2 or Hyper-V for Linux container support. WSL 2 (Windows Subsystem for Linux) is suggested, and we will not be covering Hyper-V in this guide.

To start, ensure your version of Windows Server supports WSL 2. Once you have confirmed your system supports WSL 2, open up File Explorer on Windows Server and select the “Downloads” folder. From here, you can double-click on the Docker Desktop for Windows installer EXE to start it up.

With the installer open, it will verify itself. This may take some time to complete, depending on your version of Windows Server. When the installation is verified, you’ll be required to choose either Hyper-V or WSL 2. Select “WSL 2.”

Upon choosing WSL 2, the Docker Desktop for Windows application will begin deploying Docker, as well as everything you need to run both Linux and Windows Docker containers. The deployment could take quite a while to complete, so be patient.

When the deployment is finished, installation is complete and Docker Desktop for Windows will be installed on your Windows Server. From here, launch it via the application on the desktop, and sign into the app.

How to enable Linux containers on Windows Server

WSL is required to run Linux Docker containers on Windows Server. Although Docker for Windows Desktop installs WSL, it doesn’t set you up with a Linux distribution. You will need to set one up yourself.

You must enable the “Virtual Machine Platform” feature before attempting to use WSL. Launch a Powershell window and execute the command below.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Next, use the wsl command below to download the newest version of WSL, and use the wsl –install -d command to download and install Ubuntu.

wsl --update
wsl --set-default-version 2
wsl --install -d ubuntu

Downloading and installing the Ubuntu WSL distribution shouldn’t take more than a few minutes at most. When the installation is complete, you can run the wsl -l -v command to confirm that Ubuntu is indeed installed and set up in WSL on Windows.

wsl -l -v

If the command lists Ubuntu, you’ll have successfully installed Ubuntu. You’ll now need to set the default distribution to use. You can do that with the wsl –set-version command.

wsl --set-version ubuntu 2

After Ubuntu is successfully installed in WSL on Windows Server, open up the Ubuntu terminal. You can do this by opening up the start menu on the Windows Server desktop, and selecting “Ubuntu.” This should launch the Ubuntu terminal.

With the Ubuntu terminal open, you will need to update it. You can update the Ubuntu WSL terminal with the apt update and apt upgrade commands.

sudo apt update 

sudo apt upgrade

Once the Ubuntu terminal is open, you can run a test that Docker works inside of WSL with the following commands. If it doesn’t work, you will need to re-install Docker Desktop for Windows.

docker pull hello-world

docker run hello-world

How to download Linux containers on Windows Server

To pull a Linux docker container on your Windows Server, start by opening up the Ubuntu WSL terminal. Once it is open, go to Dockerhub and find a Linux container. In this example, we’ll use Photoprism.

docker pull photoprism/photoprism

After pulling the container, it will be present in your system.

How to run Linux containers on Windows Server

To run a Linux container on Windows Server, start by launching the Ubuntu WSL terminal. Then, run docker ps -a to view all containers. You can run your Linux container by running docker run with the container ID.

docker run CONTAINER_ID

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.