Skip to content

Instantly share code, notes, and snippets.

@jimbo8098
Created December 1, 2020 00:18
Show Gist options
  • Save jimbo8098/376243cee3201cb298f4c9c15d16b266 to your computer and use it in GitHub Desktop.
Save jimbo8098/376243cee3201cb298f4c9c15d16b266 to your computer and use it in GitHub Desktop.
Start a Windows Docker Github Runner through Powershell (Server Core 2019)

When starting a new github runner in a virtualized environment I had some issues due to the environment using Server Core 2019 and therefore not shipping with the usual GUI tools. To use the runner with the Docker service by default I had to register the Github agent runner as the LocalSystem account instead.

  1. Download and install Docker and Git per their docs
  2. In your Github repo, go to the settings > actions section and click add runner. Select Windows (if it's not default) then download the agent and expand it per the instructions.
  3. Ensure you use --windowslogonaccount LocalSystem
./config.cmd --url repourl --token token --runasservice --name hostname --windowslogonaccount LocalSystem

The reason this works is that by default the LocalSystem user has access to Docker although it also has access to slews of other resources. It is probably better practice to make a user specifically for your runners with just the access they need but this is difficult on Server Core so I just close things out via the network instead.

Other ways I was able to do this was to create the service without windowslogonaccount then run:

#The runner name will be specific to your agent
$serviceName = "Github Runner"
Get-CimInstance win32_service -filter "name='$serviceName'" | Invoke-CimMethod -Name Change -Arguments @{StartName="LocalSystem"}
Restart-Service $serviceName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment