Beginner's Guide - Docker on Windows 10 - WindowsTips.net - Windows Tips and Tricks with Geek

Thursday, June 24, 2021

Beginner's Guide - Docker on Windows 10

 

Install Docker on Windows 10

Docker works cross-platform and such supports execution on a Windows host, including Windows 10 (Pro or Enterprise). This makes Windows 10 a perfect development environment for Docker use-cases. On top of this, Windows is also the only platform, for now at least, that can run Windows and Linux based containers. This is because containers share the hosts kernel, so Windows can run Windows containers and, thanks to nested virtualisation in Hyper-V, we can also run Linux containers inside of a very small Linux VM, that is 100 percent managed by Docker. Right now, however we must decide if we want Linux or Windows containers, we cannot run both at the same time.

As a prerequisite to install Docker you need to enable Hyper-V on your machine. If you do not want to use Hyper-V you can also use VirtualBox. 

To install Docker on Windows 10 we have two options.

I prefer the latter method, but just be aware, this is not a package maintained by Docker, plus you might need to provide Chocolatey with the "--ignore-checksums" parameter.

Depending on the way you installed Docker you either need to restart or open up a new PowerShell. Run "docker --version" to see if your PATH variable has been configured correctly.

By default, Docker is configured to run Linux containers and to support these Docker will create a small Hyper-V VM on your machine.

You will not be able to connect to this VM, the only way to interact with Docker is via its command line.


Our first Windows Docker container

In our taskbar, we will now also find a new icon in the form of a whale carrying tiny containers. This is Docker.

From here you can switch Docker over to "Windows containers", follow any prompts, if any, and wait for the Docker whale to be done switching over to Windows containers.

In PowerShell execute the following to download and run your first Windows based container:

"docker pull microsoft/nanoserver"

Now execute

"docker run -it microsoft/nanoserver powershell"

from your PowerShell. Docker will create a new container and attach your current shell in an interactive session with an input command line / TTY ("-it" parameter) to the process specified on the command line, in our case "powershell."

If you are unfamiliar with Nano Server, browse around, try a few things and familiarize yourself with it.

In a separate PowerShell, enter "docker ps" to see your currently running containers and get some information about them. To exit the container, simply enter "exit" until you end up in your local session

No comments:

Post a Comment