diff --git a/scripts/docker/add-docker-group.ps1 b/scripts/docker/add-docker-group.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..7af581f157b3ba3b59569fd6600c26c4163ef9e5 --- /dev/null +++ b/scripts/docker/add-docker-group.ps1 @@ -0,0 +1,7 @@ +net localgroup docker /add +net localgroup docker vagrant /add + +(Get-Content C:\ProgramData\docker\runDockerDaemon.cmd).replace('-H npipe://', '-G docker -H npipe://') | Set-Content C:\ProgramData\docker\runDockerDaemon.cmd + +# restart-service docker +# logoff and logon again diff --git a/scripts/enable-docker-insecure.ps1 b/scripts/docker/enable-docker-insecure.ps1 similarity index 52% rename from scripts/enable-docker-insecure.ps1 rename to scripts/docker/enable-docker-insecure.ps1 index bc50fb24587fa3916e78cb9c48d124a2abcd816f..f016e72c8fbfd581166d550c444f1844d4f7fbf2 100644 --- a/scripts/enable-docker-insecure.ps1 +++ b/scripts/docker/enable-docker-insecure.ps1 @@ -7,14 +7,4 @@ if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerinsecure2375"})) { Write-Host "Enabling Docker to listen on insecure port 2375" cp C:\ProgramData\docker\runDockerDaemon.cmd C:\ProgramData\docker\runDockerDaemon.cmd.bak -cat C:\ProgramData\docker\runDockerDaemon.cmd.bak | %{$_ -replace '^docker daemon -D -b "Virtual Switch"$','docker daemon -D -b "Virtual Switch" -H 0.0.0.0:2375'} | Set-Content C:\ProgramData\docker\runDockerDaemon.cmd - -Write-Host "Stopping Docker" -Stop-Service docker - -# Do not restart Docker as it creates the key.json with an unique ID -# This should not exist in the Vagrant basebox so you can spin up -# multiple Vagrant boxes for a Docker swarm etc. - -Write-Host "Removing key.json to recreate key.json on first vagrant up" -rm C:\ProgramData\docker\config\key.json +cat C:\ProgramData\docker\runDockerDaemon.cmd.bak | %{$_ -replace '^dockerd -H npipe://$','dockerd -H npipe:// -H 0.0.0.0:2375'} | Set-Content C:\ProgramData\docker\runDockerDaemon.cmd diff --git a/scripts/install-docker.ps1 b/scripts/docker/install-docker.ps1 similarity index 99% rename from scripts/install-docker.ps1 rename to scripts/docker/install-docker.ps1 index 1e1d86271755cc98ff6bba8454fd08eeaf98bbbe..98338c61be25c1cfacc7a88ca0527213d9c3e626 100644 --- a/scripts/install-docker.ps1 +++ b/scripts/docker/install-docker.ps1 @@ -5,7 +5,6 @@ wget https://aka.ms/tp5/Update-Container-Host -OutFile c:\update-containerhost.p Install-PackageProvider ContainerImage -Force - # create a Task Scheduler task which is also able to run in battery mode due # to host notebooks working in battery mode. diff --git a/scripts/patch-boot-time-for-containers.ps1 b/scripts/docker/patch-boot-time-for-containers.ps1 similarity index 100% rename from scripts/patch-boot-time-for-containers.ps1 rename to scripts/docker/patch-boot-time-for-containers.ps1 diff --git a/scripts/docker/remove-docker-key-json.ps1 b/scripts/docker/remove-docker-key-json.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..b3fb91146ba489f05bbd08e88a783ecec41d4ac5 --- /dev/null +++ b/scripts/docker/remove-docker-key-json.ps1 @@ -0,0 +1,9 @@ +# Do not restart Docker as it creates the key.json with an unique ID +# This should not exist in the Vagrant basebox so you can spin up +# multiple Vagrant boxes for a Docker swarm etc. + +Write-Host "Stopping Docker" +Stop-Service docker + +Write-Host "Removing key.json to recreate key.json on first vagrant up" +rm C:\ProgramData\docker\config\key.json diff --git a/windows_2016_docker.json b/windows_2016_docker.json index b9616f38d5b87a37e2d4cc5cf24f87289c017151..b76d76eade315ff6704cfa7ebf90cace6456c5c1 100644 --- a/windows_2016_docker.json +++ b/windows_2016_docker.json @@ -101,9 +101,11 @@ { "type": "powershell", "scripts": [ - "./scripts/install-docker.ps1", - "./scripts/patch-boot-time-for-containers.ps1", - "./scripts/enable-docker-insecure.ps1" + "./scripts/docker/install-docker.ps1", + "./scripts/docker/patch-boot-time-for-containers.ps1", + "./scripts/docker/enable-docker-insecure.ps1", + "./scripts/docker/add-docker-group.ps1", + "./scripts/docker/remove-docker-key-json.ps1" ] }, {