readme: Update readme for Windows service
@@ -48,10 +48,48 @@ See also the Advanced Usage section below.
### On Windows Server 2016
-On Windows Server 2016, the Amazon ECS Container Agent runs as a process on the
-host. Unlike Linux, the agent may not run inside a container as it uses the
-host's registry and the named pipe at `\\.\pipe\docker_engine` to communicate
-with the Docker daemon.
+On Windows Server 2016, the Amazon ECS Container Agent runs as a process or
+service on the host. Unlike Linux, the agent may not run inside a container as
+it uses the host's registry and the named pipe at `\\.\pipe\docker_engine` to
+communicate with the Docker daemon.
+
+#### As a Service
+To install the service, you can do the following:
+
+```powershell
+PS C:\> # Set up directories the agent uses
+PS C:\> New-Item -Type directory -Path $ProgramFiles\Amazon\ECS
+PS C:\> New-Item -Type directory -Path $ProgramData\Amazon\ECS
+PS C:\> # Set up configuration
+PS C:\> $ecsExeDir = "$env:ProgramFiles\Amazon\ECS"
+PS C:\> [Environment]::SetEnvironmentVariable("ECS_CLUSTER", "my-windows-cluster", "Machine")
+PS C:\> [Environment]::SetEnvironmentVariable("ECS_LOGFILE", "$ProgramData\Amazon\ECS\log\ecs-agent.log", "Machine")
+PS C:\> [Environment]::SetEnvironmentVariable("ECS_DATADIR", "$ProgramData\Amazon\ECS\data", "Machine")
+PS C:\> # Download the agent
+PS C:\> $agentVersion = "latest"
+PS C:\> $agentZipUri = "https://s3.amazonaws.com/amazon-ecs-agent/ecs-agent-windows-$agentVersion.zip"
+PS C:\> $zipFile = "$env:TEMP\ecs-agent.zip"
+PS C:\> Invoke-RestMethod -OutFile $zipFile -Uri $agentZipUri
+PS C:\> # Put the executables in the executable directory.
+PS C:\> Expand-Archive -Path $zipFile -DestinationPath $ecsExeDir -Force
+PS C:\> # Uncomment the following line to enable task IAM roles.
+PS C:\> # Note that enabling IAM roles will make port 80 unavailable for tasks.
+PS C:\> # cd '$ecsExeDir'; .\hostsetup.ps1
+PS C:\> # Install the agent service
+PS C:\> New-Service -Name "AmazonECS" `
+ -BinaryPathName "$ecsExeDir\amazon-ecs-agent.exe -windows-service" `
+ -DisplayName "Amazon ECS" `
+ -Description "Amazon ECS service runs the Amazon ECS agent" `
+ -DependsOn Docker `
+ -StartupType Manual
+```
+
+To run the service, you can do the following:
+```powershell
+Start-Service AmazonECS
+```
+
+#### As a Process
```powershell
PS C:\> # Set up directories the agent uses
