A developer named James Nugent described in a blog post the Packer template he wrote for creating a Windows AMI with OpenSSH installed and configured (by default, there is no SSH server installed or running on the free Windows AMIs owned by Amazon). He had previously shared code for using WinRM to automate a Windows instance.
I used his code to create my own AMI in us-east-2
: ami-03247dd53ecd53cba
. You can try it out yourself. The SSH user is Administrator
.
Sadly, there is a long delay between when an AWS instance launched with this AMI enters the state "running" and when the SSH server on it is running, for the same reason that password data is not immediately available, up to 15 minutes. This is just an unfortunate consequence of deploying a service (SSH) on Windows it seems.
Docker Machine is smart enough to wait for "SSH to be available", but it runs into an error when Docker Machine tries to provision it. There is an open issue in the Docker Machine project for provisioning Windows machines. They had not started working on it because there was no easy, non-interactive way out-of-the-box for connecting to a Windows machine.
Error creating machine: Error detecting OS: Error getting SSH command: ssh command error:
command : cat /etc/os-release
err : exit status 1
output : cat : Cannot find path 'C:\etc\os-release' because it does not exist.
At line:1 char:1
+ cat /etc/os-release
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\etc\os-release:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand