What is Docker?
Docker is a container technology produced by the company Docker, Inc. With Docker, developers can deploy applications in a secure, stable and isolated environment because it provides an additional layer of abstraction and automation of operating-system-level virtualization on both Windows and Linux.
How does it behave on Windows Server?
On Windows, Docker behaves exactly as it does on Linux, with the same Docker CLI, API, image format and Docker registry services. Through Docker, one can build and run native Windows apps in containers, which makes them more portable, easier to work on and simpler to deploy.
With that in mind, let’s see how you can set up Docker on Windows 2016 Server. To do this, you will need Docker Enterprise Edition for Windows Server 2016, which enables Docker containers for this particular OS. The installation package provides everything you need to get started with Docker on your Windows Server.
First, you’ll need to open a Powershell command prompt, and enter these commands:
PS> Install-Module -Name DockerMsftProvider -Force PS> Install-Package -Name docker -ProviderName DockerMsftProvider -Force PS> Restart-Computer -Force
Next, it is recommended that you test your installation by running the hello-world container, like so:
PS> docker run hello-world:nanoserver Unable to find image 'hello-world:nanoserver' locally nanoserver: Pulling from library/hello-world bce2fbc256ea: Pull complete 3ac17e2e6106: Pull complete 8cac44e17f16: Pull complete 5e160e4d8db3: Pull complete Digest: sha256:25eac12ba40f7591969085ab3fb9772e8a4307553c14ea72d0e6f98b2c8ced9d Status: Downloaded newer image for hello-world:nanoserver Hello from Docker! This message shows that your installation appears to be working correctly. <snip>
Alternatively, you can install Docker EE using a script, if you want to install manually, script automated installs, or install it on air-gapped systems. The process is quite straightforward, just as with the standard installation.
First, open a PowerShell command prompt and download the installer archive on a machine that has an internet connection, like so:
PS> invoke-webrequest -UseBasicparsing -Outfile docker.zip https://download.docker.com/components/engine/windows-server/17.03/docker-17.03.0-ee.zip
Then copy the zip file you downloaded to the machine where you want to install and run Docker. Also in a PowerShell command prompt, enter the following commands to extract the archive, register, and start the Docker service.
# Extract the archive. PS> Expand-Archive docker.zip -DestinationPath $Env:ProgramFiles # Clean up the zip file. PS> Remove-Item -Force docker.zip # Install Docker. This will require rebooting. $null = Install-WindowsFeature containers # Add Docker to the path for the current session. PS> $env:path += "$env:ProgramFiles\docker" # Optionally, modify PATH to persist across sessions. PS> $newPath = "$env:ProgramFiles\docker;" + [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) PS> [Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::Machine) # Register the Docker daemon as a service. PS> dockerd --register-service # Start the daemon. PS> Start-Service docker
Finally, check if Docker was installed properly by running the hello-world container.
PS> docker run hello-world:nanoserver
Whichever method you chose, Docker EE should now be up and running on your Windows server. Congratulations!