- Preview: Linux Containers on Windows
- Running Docker Linux Containers on Windows with LinuxKit
- Setup Docker and LinuxKit
- Try it
- Looking ahead
- More Resources:
- Linux containers on Windows 10
- Linux containers in a Moby VM
- Get started: Set up Linux Containers on Windows 10
- Prerequisites
- Install Docker Desktop
- Run Your First Linux Container
- Начало работы. Настройка контейнеров Linux в Windows 10
- Предварительные условия
- Установка Docker Desktop
- Запуск первого контейнера Linux
Preview: Linux Containers on Windows
Microsoft is getting ready for the next big update for Windows Server (check out today’s complimentary Microsoft blog post ) and some of the new features are very exciting for Docker users. One of the most important enhancements is that Docker can now run Linux containers on Windows (LCOW), using Hyper-V technology.
Running Docker Linux containers on Windows requires a minimal Linux kernel and userland to host the container processes. This is exactly what the LinuxKit toolkit was designed for: creating secure, lean and portable Linux subsystems that can provide Linux container functionality as a component of a container platform.
We’ve been busy prototyping LinuxKit support for Docker Linux containers on Windows and have a working preview for you to try. This is still a work in progress, and requires either the recently announced “Windows Server Insider” or Windows 10 Insider builds.
UPDATE: LCOW support is available in Windows 10 Fall Creators Update and in Windows Server 1709. The simplest way to try it out on Windows 10 is to install the edge variant of Docker for Windows (details). On Windows Server 1709, install EE preview.
Running Docker Linux Containers on Windows with LinuxKit
The instructions below have been tested on Windows 10 and Windows Server Insider builds 16278 and 16281.
Be sure to install Docker for Windows (Windows 10) or Docker Enterprise Edition (Windows Server Insider) before starting.
Setup Docker and LinuxKit
A preview build of LinuxKit is available by simply running the following commands in PowerShell (with Administrator rights):
$progressPreference = 'silentlyContinue' mkdir "$Env:ProgramFiles\Linux Containers” Invoke-WebRequest -UseBasicParsing -OutFile linuxkit.zip https://github.com/friism/linuxkit/releases/download/preview-1/linuxkit.zip Expand-Archive linuxkit.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\." rm linuxkit.zip
Now get a master branch build of the Docker daemon that contains preview support for Linux containers on Windows:
Start a new Docker daemon listening on a separate pipe and using a separate storage location from the default install:
$Env:LCOW_SUPPORTED=1 $env:LCOW_API_PLATFORM_IF_OMITTED="linux" .\dockerd.exe -D --experimental -H "npipe:////./pipe//docker_lcow" --data-root c:\lcow
Try it
docker -H "npipe:////./pipe//docker_lcow" run -ti busybox sh
Docker just launched a minimal VM running a LinuxKit instance hosting the Linux container!
Since this is an early preview there are some limitations, but basic Docker operations like pull and run work.
Looking ahead
Both Windows Server Insider builds and Docker support for Linux containers on Windows are in early preview mode. When GA, Docker Linux containers on Windows will improve the Docker Linux container experience for both Windows developers and server administrators. Developers will be able to more easily build and test mixed Windows/Linux Docker applications by running containers for both platforms side-by-side on the same system.
And IT-admins that prefer Windows will soon be able to easily run (mostly) Linux-only software like HAProxy and Redis on Windows systems by way of Docker Linux containers on Windows. For example, Docker Linux containers on Windows will make setting up Docker Enterprise Edition and Universal Control Plane (which relies on some Linux-only components) on Windows Server much simpler.
We hope this LinuxKit-based walkthrough will set you up to start experimenting. Feedback is always welcome! For general help and getting started with Insider builds use the Windows Feedback Hub (Windows 10), or the Windows Server Insiders Tech Community . For issues with LinuxKit and Docker support for Linux containers on Windows use the Docker for Windows issue tracker on GitHub . And let us know on Twitter if you build something cool!
More Resources:
Linux containers on Windows 10
Linux containers make up a huge percent of the overall container ecosystem and are fundamental to both developer experiences and production environments. Since containers share a kernel with the container host, however, running Linux containers directly on Windows isn’t an option. This is where virtualization comes into the picture.
Linux containers in a Moby VM
To run Linux containers in a Linux VM, follow the instructions in Docker’s get-started guide.
Docker has been able to run Linux containers on Windows desktop since it was first released in 2016 (before Hyper-V isolation or Linux containers on Windows were available) using a LinuxKit based virtual machine running on Hyper-V.
In this model, Docker Client runs on Windows desktop but calls into Docker Daemon on the Linux VM.
In this model, all Linux containers share a single Linux-based container host and all Linux containers:
- Share a kernel with each other and the Moby VM, but not with the Windows host.
- Have consistent storage and networking properties with Linux containers running on Linux (since they are running on a Linux VM).
It also means the Linux container host (Moby VM) needs to be running Docker Daemon and all of Docker Daemon’s dependencies.
To see if you’re running with Moby VM, check Hyper-V Manager for Moby VM using either the Hyper-V Manager UI or by running Get-VM in an elevated PowerShell window.
Get started: Set up Linux Containers on Windows 10
The exercise will walk through creating and running Linux containers on Windows 10.
In this quick start you will accomplish:
This quick start is specific to Windows 10. Additional quick start documentation can be found in the table of contents on the left-hand side of this page.
Prerequisites
Please make sure you meet the following requirements:
- One physical computer system running Windows 10 Professional, Windows 10 Enterprise, or Windows Server 2019 version 1809 or later
- Make sure Hyper-V is enabled.
Install Docker Desktop
Download Docker Desktop and run the installer (You will be required to login. Create an account if you don’t have one already). Detailed installation instructions are available in the Docker documentation.
Run Your First Linux Container
In order to run Linux containers, you need to make sure Docker is targeting the correct daemon. You can toggle this by selecting Switch to Linux Containers from the action menu when clicking on the Docker whale icon in the system tray. If you see Switch to Windows Containers , then you are already targeting the Linux daemon.
Once you’ve confirmed you are targeting the correc daemon, run the container with the following command:
docker run --rm busybox echo hello_world
The container should run, print «hello_world», then exit.
When you query docker images , you should see the Linux container image that you just pulled an ran:
docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 59788edf1f3e 4 weeks ago 3.41MB
Начало работы. Настройка контейнеров Linux в Windows 10
Это упражнение охватывает создание и запуск контейнеров Linux в Windows 10.
В рамках этого краткого руководства вы сможете выполнить следующие действия:
Это краткое руководство применимо только к Windows 10. Дополнительную документацию по быстрому началу работы можно найти в содержании в левой части этой страницы.
Предварительные условия
Убедитесь, что ваша система отвечает следующим требованиям:
- Одна физическая компьютерная система под управлением Windows 10 Профессиональная, Windows 10 Корпоративная или Windows Server 2019 версии 1809 или более поздней версии.
- Убедитесь, что включена технология Hyper-V.
Установка Docker Desktop
Скачайте Docker Desktop и запустите установщик. Вам потребуется войти в систему. Создайте учетную запись, если у вас ее нет. Подробные инструкции по установке доступны в документации по Docker.
Запуск первого контейнера Linux
Чтобы запустить контейнеры Linux, необходимо убедиться в ориентировании Docker на требуемую управляющую программу. Чтобы проверить это, щелкните значок Docker с изображением кита на панели задач и выберите Switch to Linux Containers в меню действий. Если вы видите Switch to Windows Containers , в качестве целевой уже задана управляющая программа Linux.
Убедившись в ориентировании на требуемую управляющую программу, запустите контейнер с помощью следующей команды:
docker run --rm busybox echo hello_world
Должен запуститься контейнер и отобразиться текст «hello_world». Затем будет выполнен выход.
При запросе docker images должен отобразиться образ контейнера Linux, который вы только что извлекли и запустили:
docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 59788edf1f3e 4 weeks ago 3.41MB