Dockerfile on Windows
Optimize Windows Dockerfiles

Manual creation of custom docker image

New-Item -ItemType file -Name test.txt -Value foo
docker ps
docker stop 25
docker commit 25 my-nano-image
docker images
docker history my-nano-image


Automated way 
mkdir web
cd web
New-Item -ItemType file -Name Dockerfile
#edit docker file - see attached samples
docker build --help
# folder now is c:\web, that is why "<strong>.</strong>" is OK for the cmd below
# create index.html
docker build -t web .
docker images
docker history web
# create v2 - edit index.html <h1>hello world v2</h1>
docker build -t web:v2 .
docker build --help #no cache option
docker images
docker tag web:latest web:v1
docker images
docker rmi web:latest
docker images #now we have v1 & v2 tags
docker tag web:v2 web:latest
docker images


Go to Docker Hub Registry and create account, then tag images with your account
docker tag web:latest <accountname>/web:latest
docker tag web:v1 <accountname>/web:v1
docker images
docker rmi # delete tags
docker login #l/p
docker push <accountname>/web:latest
docker push <accountname>/web:v1
docker rmi # remove uploaded
docker pull <accountname>/web:latest
docker images


Working with Container Volumes
docker run -it -v c:\containerdata:c:\mydata wincontainers/web powershell
# go to container
ls c:\mydata #files are there
New-Item -ItemType file -Name file3.txt -value "hello world"
exit
docker ps -a
docker rm 25
docker ps -a 
#persistant volume - docker construct
docker run -it -v mydata:c:\mydemo
# ^ data volume my data which will be mounted to folder c:\mydemo in container
# docker data volume shared among other containers. ^
docker run -it -v mydata:c:\mydemo wincontainers/web powershell
New-Item -ItemType file -Name test.txt -value "hello world"
# CTRL +PQ & new container
docker volume --help
docker rm -f  $(docker ps -q)
docker volume ls
docker volume rm mydata
docker run -it --memory 1g --cpu-percent 20 microsoft/nanoserver


Manage data in containers
Persistent Docker volumes with Azure File Storage

Limit a container's resources
Resource management in Docker

Container Networking
Windows Container Networking
Virtualization Blog - Windows Container Networking
A Brief Primer on Docker Networking Rules: EXPOSE, -p, -P, --link

Get-ContainerNetwork
help New-ContainerNetwork   # -Mode NAT, Transparent, L2Bridge & L2Tunnel
docker run -it microsoft/nanoserver
ipconfig
exit
stop-service docker
Get-ContainerNetwork | Remove-ContainerNetwork
# edit docker daemon file 
New-Item -ItemType file -Path c:\programdata\docker\config\ -Name daemon.json
ii c:\programdata\docker\config\ # Invoke-Item
# insert into json file
#{
#"fixed-cidr" : "10.0.0.0/24"
#}
start-service docker
Get-ContainerNetwork #see new NAT network address space
docker run -it microsoft/nanoserver
ipconfig
docker run -it -p 80:80 wincontainers/web
ipconfig
# CTRL+PQ
docker ps
# due to NAT Limitations you can't see it on host machine


Create Transparent Network
stop-service docker
Get-ContainerNetwork | Remove-ContainerNetwork
# edit docker daemon file 
New-Item -ItemType file -Path c:\programdata\docker\config\ -Name daemon.json
ii c:\programdata\docker\config\ # Invoke-Item
# insert into json file
#{
#  "bridge" : "none"
#}
Start-service docker
Get-ContainerNetwork # don't see anything
docker network create -d transparent TNET
Get-ContainerNetwork
docker network ls
docker run -it --network=TNET microsoft/nanoserver
ipconfig  # see IP from DHCP server


Deploying a Multi-container Application on Azure
Manage a Docker private registry as a first-class Azure resource
Azure Container Service

Overview of Docker Compose - tool for defining and running multi-container Docker applications
Install Docker Compose

Deploy Multi Container App Demo
mikepfeiffer/movieapp - Dockerized Mulli-Container App with IIS and SQL
Downloading Git Client for Windows

1. create Azure Account
2. resource group Docker
3. Deploy VM 2016 Datacenter with Docker
4. RDP
5.
docker images
docker pull microsoft/mssql-server-windows-express
docker pull microsoft/aspnet
# Install Docker Compose
Invoke-WebRequest https://dl.bintray.com/docker-compose/master/docker-compose-Windows-x86_64.exe -UseBasicParsing -OutFile $env:ProgramFiles\docker\docker-compose.exe
# install Git Client
# copy to Clipboard git URL
c:
cd\
git clone https://github.com/mikepfeiffer/movieapp.git
<a href="https://github.com/mikepfeiffer/movieapp.git"></a>cd movieapp
ls
docker-compose
docker-compose build
docker images # see movieapp_iis & sql
docker-compose up -d
docker ps

6. In Azure - Go to Container Host-nsg Network Security Group, Inbound security rules and add http  rule
7. stop app
docker-compose down
docker ps 
docker ps -a


Additional Resources:
Windows Containers on Windows Server
Windows Container Samples