Demo script for Docker in Azure against Linux and Windows containers

These are the overall steps I followed in order to create a Docker demo in Azure, both against Linux and Windows containers. They are not very detailed, mostly because on the Windows side things are in preview. But the pointers should help.

Basically, steps allow you to install Docker client in Windows, setup a Linux host VM in Azure and finally setup a Windows docker host VM in Azure.

Of course, you could arrive at these steps looking here and there. What I'm doing here is to outline the steps I followed in a single place.

Suggestions welcome.

First comes the Docker Windows Client installation:

  • install Docker Windows client
 from https://chocolatey.org/
 
@powershell -NoProfile -ExecutionPolicy Bypass -Command `
 "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
 
 from https://chocolatey.org/packages/docker
choco install docker
  • install openssl client on Windows
 https://slproweb.com/products/Win32OpenSSL.html

Next in line is the creation of the Docker Linux Host on Azure:

  • create Azure Linux VM docker engine host
 create an Ubuntu 14.04 Linux VM in the Azure Portal.
  • install docker in the host
 https://docs.docker.com/installation/ubuntulinux/#installation
  • protect Docker in the Linux host
 https://docs.docker.com/articles/https/
Copy ca.pem, cert.pem and key.pem to Windows client's %USERPROFILE%\.docker
  • check communication between Docker client and Linux host
 docker --tls -H tcp://<Linux Docker host FQDN, *.cloudapp.net>:4243 info
  • have some fun
 set DOCKER_HOST=tcp://<Linux Docker host FQDN, *.cloudapp.net>:4243
 set DOCKER_TLS_VERIFY=TRUE

docker run ubuntu:14.04 /bin/echo 'Hello world'
docker run -t -i /bin/bash
docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
docker ps
docker logs <id>
docker stop <id>
docker ps
docker version (notice Windows client & Linux server)
  • Host a web app on the Docker Linux Host
 docker run -d -P training/webapp python app.py
docker logs <id>
<open endpoint in Azure, same public & private ports>
docker run -d -p <endpoint>:5000 training/webapp python app.py
navigate to https://<Linux Docker host FQDN, *.cloudapp.net>:<endpoint>/

Finally, we create the Windows Docker Host on Azure, a Windows Server 2016 Technical Preview version.

For this part, we could create this VM manually, configure its endpoints and other plumbing.

But, Visual Studio provides a better experience by allowing to create a new host from the "Publish..." dialog (announcement here).

  • publish web app to Windows container, creating the Windows container VM host in the process
 install https://www.microsoft.com/en-us/download/details.aspx?id=48738
install https://visualstudiogallery.msdn.microsoft.com/0f5b2caa-ea00-41c8-b8a2-058c7da0b3e4
 create a new MVC app
 publish project to Docker Container option, create new VM
  • connect to Windows Server 2016 docker host
 set DOCKER_HOST=tcp://<Windows Docker host FQDN, *.cloudapp.net>:2376
set DOCKER_TLS_VERIFY=FALSE
copy Windows certs to %USERPROFILE%\.docker\
docker ps

 

https://msdn.microsoft.com/virtualization/windowscontainers/containers\_welcome

https://weblogs.asp.net/scottgu/announcing-windows-server-2016-containers-preview

https://msopentech.com/blog/2014/08/15/getting\_started\_docker\_on\_microsoft\_azure/

https://azure.microsoft.com/en-us/blog/docker-client-for-windows-is-now-available/

https://docs.docker.com/windows/started/

https://docs.docker.com/installation/windows/ (this is for creating a Linux Container Host on top of virtualbox in Windows)

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-docker-swarm/

https://docs.docker.com/installation/ubuntulinux/\#installation (same as above; for Docker installation on the Ubuntu 14.04 created in Azure)

https://docs.docker.com/articles/https/ (for protecting the Docker endpoints)

https://msdn.microsoft.com/virtualization/windowscontainers/quick\_start/manage\_docker (interesting, but it doesn't include how to manage the Windows Docker Host from the Windows Docker client)

https://msdn.microsoft.com/virtualization/windowscontainers/about/work\_in\_progress (important, since there is stuff you can't do - yet)

https://msdn.microsoft.com/en-us/library/azure/mt125409.aspx

https://blogs.msdn.com/b/stevelasker/archive/2015/08/24/why-doesn-t-docker-tools-for-visual-studio-2015-show-the-new-button.aspx (I hit this issue, and installing the right versions was the solution)