I said it earlier in a previous post. The world is changing. And especially the world of Microsoft Developers. In my post about modern tools I presented a list with tools that a developers must have in his toolbox. This list did not contain a lot of Microsoft tools.
In the ALM space, and here I focus on Team Foundation Server (TFS) and Visual Studio Online (VSO) a lot of things are changing too. TFS and VSO become more and more open with REST API’s, allowing companies to integrate and connect with their own (non-microsoft tool). In my posts about integrating TeamCity with TFS You can see a vivid example of this.
This post is about Docker. Docker is a technology that allows you to run applications within a container. This container contains all settings, prerequisites etc to run your application. This makes a container extremely useful for shipping (hence the metaphor of a container) and is widely used in Continuous Delivery scenarios. Companies like Spotify, Uber and PayPal use Docker to enable their fast delivery of software. The CTO of Docker explains it here on YouTube.
Within the Microsoft space we do not see a lot of usage of Docker containers. This is mostly due to the fact that Windows cannot run Docker containers (yet! Take a look at Windows Nano..). You need to run Linux to be able to run Docker.
Personally I really like the concept of containers. Having everything packed within the container allows companies to move faster towards production. Developers make it work in their container and it runs everywhere. Continuous Delivery, and DevOps practices in action.
So, I wanted to gain some experience with Docker and started to look around for resources. I found the following resources
- Docker for .NET developers on Channel 9
- Windows client for Docker
- Running ASP.Net 5 in a docker container
- The Docker enabled Virtual Machine on Azure
- Docker User guide
After following these steps I had quite some insights in how Docker worked. But still, I found it hard to get a grip on how to make stuff really work. After following the ASP.Net series I had the idea that I missed how Docker really worked, So I decided to do it on the native OS, from scratch.
In the rest of this post I will walk you through my steps of creating a Linux machine with Docker, and making it accesible via Remote Desktop. We will use that as the foundation for creating a Docker container with a Visual Studio Build vNext Agent.
To get started we need a machine to start on. I my case I created a Linux Virtual Machine on Azure. I browsed the internet and found this great tutorial that you can use to create a Linux VM, enable Remote Desktop, install a desktop and open the endpoint in Azure to access this machine.
The steps that you have to take (in short) . Some steps (marked bold) are different from the tutorial.
- Log in to your Azure Subscription
- Create a VM from the gallery and choose Ubuntu Server 14.04! (In the tutorial a 12.05 image is created)
- I gave it 3.5 GB RAM (A2 image)
- Don’t use the SSH key, but provide a password.
- Create the VM
- Download Putty ( http://aka.ms/putty )and connect to the VM using the name you provided (name.cloudapp.net)
- Install the Ubuntu Desktop
- Install the xRDP protocol
- Enable the Azure endpoint for Remote Desktop
After finishing these steps, you have a fully functional Azure machine. Only when connecting with Remote Desktop the Ubuntu 14.04 crashes. After researching (a lot !) I found out that the desktop manager of Ubuntu 14.04 does not work anymore with xRDP.
Following this walkthrough (THANKS!) I was able to get a Remote Desktop Connection working for my machine.
When you now open a Remote Desktop Client and connect to your Azure machine you have a fully functional desktop. This makes a lot easier to edit files and copy things around and find stuff on the internet.
Setting up Docker
Now we want to run Docker on this machine. I connected with Putty to my machine and followed the steps described in the Docker User Guide.
With this image, the only thing I needed to do was to run this command
After that you are able to run Docker containers. If you run the command
You should see this
NB: If you are wondering what sudo means before every command(just like me in the beginning) it means…Super User Do. In other words run this command as Super User. Something like elevated privileges in Windows. If you want to run all docker commands as Super User (or shut down User Account Control in Windows), follow these steps here.
Now you have your Linux machine up and running and Docker installed, I would highly recommend that you follow the instructions in the Docker User Guide. They provide a lot of useful insights in how to work with Docker.
In my next post I will talk about how to create a Docker container which runs a Visual Studio Build vNext agent