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
@powershell -NoProfile -ExecutionPolicy Bypass -Command `
 "iex ((new-object net.webclient).DownloadString(''))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
choco install docker
  • install openssl client on Windows

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
  • protect Docker in the Linux host
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, *>:4243 info
  • have some fun
 set DOCKER_HOST=tcp://<Linux Docker host FQDN, *>:4243

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
docker logs <id>
<open endpoint in Azure, same public & private ports>
docker run -d -p <endpoint>:5000 training/webapp python
navigate to http://<Linux Docker host FQDN, *>:<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
 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, *>:2376
copy Windows certs to %USERPROFILE%\.docker\
docker ps\_welcome\_started\_docker\_on\_microsoft\_azure/ (this is for creating a Linux Container Host on top of virtualbox in Windows)\#installation (same as above; for Docker installation on the Ubuntu 14.04 created in Azure) (for protecting the Docker endpoints)\_start/manage\_docker (interesting, but it doesn't include how to manage the Windows Docker Host from the Windows Docker client)\_in\_progress (important, since there is stuff you can't do - yet) (I hit this issue, and installing the right versions was the solution)