Skip to content

Instantly share code, notes, and snippets.

@bgelens
Last active November 12, 2016 21:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgelens/152fdc075b6ffcf639da775958076c6a to your computer and use it in GitHub Desktop.
Save bgelens/152fdc075b6ffcf639da775958076c6a to your computer and use it in GitHub Desktop.
Install-Module -Name xPSDesiredStateConfiguration -Force
[DscLocalConfigurationManager()]
configuration LCM {
Settings {
RebootNodeIfNeeded = $true
ActionAfterReboot = 'ContinueConfiguration'
}
}
configuration Win10ContainerHost {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName xPSDesiredStateConfiguration
node localhost {
WindowsOptionalFeature HyperV {
Ensure = 'Enable'
Name = 'Microsoft-Hyper-V-All'
}
WindowsOptionalFeature Containers {
Ensure = 'Enable'
Name = 'Containers'
}
xRemoteFile DockerD {
DestinationPath = 'C:\Program Files\docker\dockerd.exe'
Uri = 'https://master.dockerproject.org/windows/amd64/dockerd.exe'
}
xRemoteFile DockerClient {
DestinationPath = 'C:\Program Files\docker\docker.exe'
Uri = 'https://master.dockerproject.org/windows/amd64/docker.exe'
}
Environment DockerEnv {
Path = $true
Name = 'Path'
Value = 'C:\Program Files\docker\'
}
script EnableDockerService {
GetScript = {
$result = if (Get-Service -Name Docker -ErrorAction SilentlyContinue) {'Service Present'} else {'Service Absent'}
return @{
GetScript = $GetScript
SetScript = $SetScript
TestScript = $TestScript
Result = $Result
}
}
SetScript = {
& 'C:\Program Files\docker\dockerd.exe' --register-service
}
TestScript = {
if (Get-Service -Name Docker -ErrorAction SilentlyContinue) {
return $true
} else {
return $false
}
}
DependsOn = '[xRemoteFile]DockerD'
}
service DockerD {
Name = 'Docker'
State = 'Running'
DependsOn = '[Script]EnableDockerService'
}
Registry VSmbDisableOplocks {
Ensure = 'Present'
Key = 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Containers'
ValueName = 'VSmbDisableOplocks'
ValueData = 1
ValueType = 'Dword'
}
}
}
LCM
Set-DscLocalConfigurationManager -Path .\LCM -Verbose
Win10ContainerHost
Start-DscConfiguration .\Win10ContainerHost -Wait -Verbose -Force
@PlagueHO
Copy link

Awesome script - I actually did a search for DSC for containers on Windows Server 2016 - but didn't think to include Windows 10! Doh! Finding this would have actually saved me a lot of effort! Doh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment