Skip to content

Instantly share code, notes, and snippets.

@jeremyje
Last active June 22, 2020 21:20
Show Gist options
  • Save jeremyje/e9488a467d4f301a11b3ba7b643f38ba to your computer and use it in GitHub Desktop.
Save jeremyje/e9488a467d4f301a11b3ba7b643f38ba to your computer and use it in GitHub Desktop.
Setup Docker on Windows Server
# https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile
# Sample Dockerfile
# Indicates that the windowsservercore image will be used as the base image.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Metadata indicating an image maintainer.
LABEL maintainer="jshelton@contoso.com"
# Uses dism.exe to install the IIS role.
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
# Creates an HTML file and adds content to this file.
RUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html
# Sets a command or process that will run each time a container is run from the new image.
CMD [ "cmd" ]
# https://cloud.google.com/compute/docs/containers#docker_on_windows
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
netsh netkvm setparam 0 *RscIPv4 0
reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0x0 /f
FROM mcr.microsoft.com/windows/servercore/iis
WORKDIR /inetpub/wwwroot
# Invoke-WebRequest -Uri "https://gist.githubusercontent.com/jeremyje/e9488a467d4f301a11b3ba7b643f38ba/raw/install-docker.ps1" -OutFile "docker.ps1"
Write-Output "Installing Docker"
Install-Module DockerMsftProvider -Force
Install-Package Docker -ProviderName DockerMsftProvider -Force
net start docker
docker container run hello-world:nanoserver
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/jeremyje/e9488a467d4f301a11b3ba7b643f38ba/raw/install-docker.ps1" -OutFile "docker.ps1"
# Invoke-WebRequest -Uri "https://gist.githubusercontent.com/jeremyje/e9488a467d4f301a11b3ba7b643f38ba/raw/install-gcloud.ps1" -OutFile "install-gcloud.ps1"; .\install-gcloud.ps1
Invoke-WebRequest -Uri "https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe" -OutFile "GoogleCloudSDKInstaller.exe"
.\GoogleCloudSDKInstaller.exe
#Invoke-WebRequest -Uri "https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip" -OutFile "google-cloud-sdk.zip"
#Expand-Archive -LiteralPath 'google-cloud-sdk.zip' -DestinationPath .
#.\google-cloud-sdk\install.bat
# Invoke-WebRequest -Uri "https://gist.githubusercontent.com/jeremyje/e9488a467d4f301a11b3ba7b643f38ba/raw/run.ps1" -OutFile "run.ps1"
Remove-Item Dockerfile
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/jeremyje/e9488a467d4f301a11b3ba7b643f38ba/raw/iis.Dockerfile" -OutFile "Dockerfile"
docker build -t iis .
docker rm -f iis-container
docker run -d -p 8000:80 --name iis-container iis
docker logs iis-container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment