How can I run Docker in a AWS Windows Server environment?
Asked Answered
H

4

19

Thing I'd tried:

Toolbox on Windows Server 2012 R2. Disabled Hyper-V to allow virtualbox. I cannot enable virtualization as it's on the physical bios.

Installed Docker EE on Windows Server 2016 w/Containers EC2. Installed correctly. Daemon is running. BUT, I can't pull a single image beside the hello-world:nanoserver. So I hunted down the windowsservercore and nanoserver, still doesn't work because they are out of date. The repo from the frizzm person at Docker.com doesn't work when you try to pull it.

Started again with a fresh Windows Server 2016 instance. I disabled Hyper-V and installed ToolBox. Doesn't work.

How do I run Docker in a windows server environment in AWS?

All of the vids/tuts seem so simple, but I sure can't get it to work. I'm at a lose.

Harper answered 15/9, 2017 at 22:24 Comment(6)
Why are you using Windows?Terrorist
Because, myself am not a Linux programmer, all of our environments, UI tests(selenium) and programmers work in a windows (VS) environment. I had thought about using the AWS Linux AMI... it had the docker built in. But I don't understand if all our .NET applications, services and test libraries will function the same in LinuxHarper
So are the Docker images running Windows?Terrorist
@MattSchuchard Windows Server 2016 supports Windows Docker Images. It's Docker for Windows running Windows apps. Docker isn't Linux only anymore. docker.com/docker-windows-serverLapsus
@Harper It's unlikely everything will run on Linux without modification. It's possible to write .NET cross platform apps, but it's very unlikely one made on Windows for Windows will work as is on Linux.Lapsus
I followed a blog tutorial I found in the docker documents for Windows Server 2016. That helped. But I still am not advance enough in docker to write my own containers. My end goal would be to utilize the selenium/hub, selenium/grid images found on hub.docker.com I still don't understand why I can't just install Docker Toolbox so I can follow along with other tutorials. Why can't toolbox work on windows server?Harper
V
22

You don't actually need to install Docker for Windows (formerly known as the Docker Toolbox) in order to utilize Docker on Windows Server.

First, it's important to understand that there are two different types of containers on the Windows Server 2016 platform: Windows Containers and Hyper-V containers.

  • Windows Containers - runs on top of the Windows Server kernel, no virtual machines used here
  • Hyper-V Containers - virtual machine containers, each with their own kernel

There's also a third option that runs on top of Hyper-V called Linux Containers on Windows (LCOW), but we won't get into that, as it appears you're specifically asking about Windows containers.

Here are a couple options you can look at:

Bare Metal Instances on AWS

If you absolutely need to run Windows Hyper-V containers on AWS, or want to run Linux containers with Docker for Windows, you can provision the i3.metal EC2 instance type, which is a bare metal instance. You can deploy Windows Server 2016 onto the i3.metal instance type, install Hyper-V, and install Docker for Windows. This will give you the ability to run both Linux containers (under a Hyper-V Linux guest), Hyper-V containers, and Windows containers.

ECS-Optimized AMI

Amazon provides an Amazon Machine Image (AMI) that you can deploy EC2 instances from, which contains optimizations for the Amazon Elastic Container Service (ECS). ECS is a cloud-based clustering service that enables you to deploy container-based applications across an array of worker nodes running in EC2.

Generally you'll use ECS and the ECS-optimized AMI together to build a production-scale cluster to deploy your applications onto.

Windows Server 2016 with Containers AMI

There's also a "Windows Server 2016 with Containers" AMI available, which isn't the same as the ECS-optimized AMI, but does include support for running Docker containers on Windows Server 2016. All you have to do is deploy a new EC2 instance, using this AMI, and you can log into it and start issuing Docker commands to launch Windows containers. This option is most likely the easiest option for you, if you're new to Windows containers.

Vidavidal answered 24/5, 2018 at 22:5 Comment(6)
>There's also a third option that runs on top of Hyper-V called Linux Containers on Windows (LCOW), but we won't get into that, as it appears you're specifically asking about Windows containers. What is this third option? I've tried creating the Windows Server 1709 with Containers AMI, but am unable to launch LCOW with it.Infinity
The Windows Server 2016 with Containers AMI come with an extremely outdated version of docker. As soon as you install the latest version the docker daemon refuses to start as it doesn't have hyper-v enabled. Has anyone got a solution for that?Sutra
I tried Windows Server 2016 with Containers AMI. But not be able to pull an image such as php and postgres. more detail here #54286873Interlocutory
@Sutra there is ami for windows server 2019 with container it has docker version 17Interlocutory
Thanks for a beautifully crafted answer and very, very helpful. Thanks.Jess
You cannot run Linux containers on a Windows EC2 unless you use a "bare metal" instance. Period. Running a Linux container on Windows requires Hyper-V, which in turns requires to enable nested virtualization, which you can only do if you have access to the processor of the host machine, which you cannot do in a regular, cloud EC2 instance. TL;DR: Avoid using Windows Server AT ALL COSTS. In a nutshell, it has 0 benefits and infinite drawbacks.Glinys
M
14

EC2 instances do not allow for nested virtualization (EC2 instances are themselves virtual machines). Docker for Windows uses Hyper-V under the hood, and Docker Toolbox uses Virtualbox under the hood, so neither of those solutions are viable.

Even if you were able to run them on a Windows EC2 instance, the performance wouldn't be that great due to the fact that Docker for Windows mounts files into the Docker VM via Samba, which is not very fast.

If you want to run Linux containers, you should probably run them on Linux. It's very fast to get set up, and all of the Docker commands that you're used to with Docker for Windows should still work.

Moral answered 25/1, 2018 at 20:34 Comment(3)
There is no reason to downvote this answer just because it doesn't solve the problem the OP has. Sometimes the answer is "it's not possible", such as in this case. The OP didn't specify if they're trying to run Windows or Linux containers in Docker Desktop on Windows in AWS, and that makes a big difference in AWS based on the technologies used and limitations in Windows. If the question is how to run Linux containers in Docker Desktop on Windows in AWS, the correct answer is "it's not possible" (as explained in this answer). Don't downvote someone just because the answer is bad news.Grice
no need to downvote, just upvote what is the better lead.Guzzle
Not sure when this didn't become a correct answer, but I am most certainly running docker (which I've installed) on a Windows Server EC2 instance. In which case, it is not a correct or valid answerDowden
S
0

It is possible to run docker on windows. Run the following command to set it up.

docker-machine create --driver amazonec2 aws01

What this command does is create a new EC2 linux instance, and connects up docker to that linux instance. When docker commands are run on your windows instance the docker commands actually are sent to the linux instance, executed, and the results are returned to the windows EC2 instance.

Here's Docker's documentation on it. I hope this helps. https://docs.docker.com/machine/drivers/aws/#aws-credential-file

Schumer answered 1/6, 2018 at 15:14 Comment(0)
D
0

I know this contradicts your question a little; but you might also consider running it on one of the new ec2 Mac OS instances, which are bare metal. Worked for me.

Desolate answered 9/3, 2021 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.