Quickstart for Docker on Windows
Installation of Docker Runtime
Step 1 – Launch a Powershell (as Administrator) window
Step 2 - Invoke-WebRequest "https://master.dockerproject.org/windows/x86_64/docker.zip" -OutFile "$env:TEMP\docker.zip" -UseBasicParsingStep 3 - Expand-Archive -Path "$env:TEMP\docker.zip" -DestinationPath $env:ProgramFiles
Step 4 and 5 – Sets correct ENV variables and persists commands across reboots
# Add path to this PowerShell session immediately
$env:path += ";$env:ProgramFiles\Docker"# For persistent use after a reboot
$Path = [Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("Path", $Path + ";$env:ProgramFiles\Docker", [EnvironmentVariableTarget]::Machine)
That’s it for the installation of the docker runtime
Creating your first Dockerized App (Package – Asp.net , IIS and a simple index.html app)
In a simple text file (called DockerFile, case doesn’t matter) – add the following lines. This file should sit in the root folder where your project (app code) sits.
FROM microsoft/iisRUN mkdir c:\MyProjects\MyApp
RUN powershell -NoProfile -Command \
Install-WindowsFeature NET-Framework-45-ASPNET; \
Install-WindowsFeature Web-Asp-Net45; \
Import-Module IISAdministration; \
New-IISSite -Name "MyApp" -PhysicalPath C:\myapp -BindingInformation "*:8000:"
EXPOSE 8000
ADD bin/ /myapp
The EXPOSED port is not where the app will run – it is simply for YOU (the user) to interact with the running container.
The rest of the commands (FROM, RUN..are self explanatory)
The ADD command is where you can specify your custom app – in a presumed bin folder. So your folder structure should look like
Building the Container and Running the App
To build and run the container image, in a powershell prompt (inside the root folder)
docker build .
Browse to http://127.0.0.1/index.html to see your Dockerized App running!
Summary
This was meant as a quick start for getting your hands dirty with Docker on Windows. There’s tons of options and variations here (such as optional parameters to pass in, ENTRYPOINT for your app etc.), but this will get you started.
Leave a Reply