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:

  1. Installed Docker for Windows
  2. Run a simple Linux container using Linux Containers on Windows (LCOW)

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 or Enterprise with Fall Creators Update (version 1709) or later
  • Make sure Hyper-V is enabled.

Hyper-V isolation: Linux Containers on Windows require Hyper-V isolation on Windows 10 in order to provide developers with the the appropriate Linux kernel to run the container. More about Hyper-V isolation can be found on the About Windows containers page.

Install Docker for Windows

Download Docker for Windows 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.

If you already have Docker installed, make sure you have version 18.02 or later to support LCOW. Check by running docker -v or checking About Docker.

The 'experimental features' option in Docker Settings > Daemon must be activated to run LCOW containers.

Run Your First LCOW Container

For this example, a BusyBox container will be deployed. First, attempt to run a 'Hello World' BusyBox image.

docker run --rm busybox echo hello_world

Note that this returns an error when Docker attempts to pull the image. This occurs because Dockers requires a directive via the --platform flag to confirm that the image and host operating system are matched appropriately. Since the default platform in Windows container mode is Windows, add a --platform linux flag to pull and run the container.

docker run --rm --platform linux busybox echo hello_world

Once the image has been pulled with the platform indicated, the --platform flag is no longer necessary. Run the command without it to test this.

docker run --rm busybox echo hello_world

Run docker images to return a list of installed images. In this case, both the Windows and Linux images.

docker images

REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
microsoft/nanoserver   latest              105d76d0f40e        4 days ago          652 MB
busybox                latest              59788edf1f3e        4 weeks ago         3.41MB

Tip

Bonus: See Docker's corresponding blog post on running LCOW.

Next Steps