Deploy Staytus on Docker Cloud

If you already have a Docker Cloud that is integrated with a Cloud service, then click this button to deploy Staytus immediately.

But if you don’t, we can set it up.

What to do:

Create free Docker login https://docs.docker.com/docker-id/ and log into https://cloud.docker.com

Now you have a free user that can have one private or unlimited public builds. Now leave this and move on to the next step.

word-image-9

Create free Azure login https://azure.microsoft.com/en-us/free/

This process is also rather painless, but it could take some time (or not). You need a MSN account if you do not have this already

word-image-10

Integrate Docker Cloud with Azure

This process is a bit more technical. First, you need to access the non-swarm mode of Docker Cloud. Login using Chrome, not Firefox.

If your cloud.docker.com looks like this, you need to turn off “Swarm mode”:

word-image-12

Then you will get this:

Click on “Cloud Settings

Find “Cloud Providers” and click on the “Connection” link on the right for Microsoft Azure. As you can see, it is possible to choose several others, which will work perfectly as well, but they all have different integration procedure.

Open CHROME (Firefox does not work for some reason) and follow the instructions on: https://docs.docker.com/docker-cloud/infrastructure/link-azure/

Click on the big button “Download Management Certificate” with Chrome. With Firefox, this button will not respond.

What to do – Updated:

Staytus is an open source solution for publishing the status of your services, and will be the target software that we will deploy in Docker Cloud to run in Azure.

We are going to install a fork of Staytus (https://github.com/galexrt/staytus) that has a docker-compose.yml file ready for Docker Cloud.

Docker Cloud’s job is to deploy and maintain Container Images on a Cloud Service. In order to create a Container, Docker Cloud first need to have a Virtual Machine where the Container can be deployed and run. This VM is called a Node and it belongs to a Node Cluster.

How to create a Node Cluster in Docker Cloud? Navigate to “Node Clusters” and click “Create”:

Example Node cluster setup:

Click “Launch node cluster” and this will create a Node Cluster with one Node that runs in Azure. Navigate to the Node and find “Timeline” to see what is happening behind the scenes.

After 5-6 minutes, the Node is ready to serve.

In Azure, you will find this Node under Virtual Machines (Classic). Notice the instance guid: f41fb646.

Now you are ready to push the button under and it will create a Stackfile based on the docker-compose.yml file inside the https://github.com/galexrt/staytus repository. A Stackfile is the Docker Cloud way of setting up running containers.

Click on “Create and Deploy

If the Containers did not start, check the Timeline and the Logs that you find when clicking on the links in the “Services” area. Perhaps try upgrading the size of your Node. This Staytus Stackfile needs 2-3GB memory VM because of the NodeJS runtime.

You can follow the progress of deployment from the Timeline tab, and when everything is running, you click on the Service or Container Endpoint. Just be sure to remove the tcp:// from the url in the browser.

Nice! With one click we deployed Staytus to Azure and it’s now ready to use. Except setting up Docker Cloud with Azure, this was almost one-two-ish click deployment 🙂

So what the catch? Well, the database follows the Node through something called volumes. The database is persisted on the Node (the Docker Host) which means that when redeploying the Container it will not lose data. However, if the Node goes down so does the data. In Production, the database would probably be backed up somewhere else or be an Azure SQL or Amazon RDS or something similar.

What to do – Updated:

Do it again, but this time Docker Cloud is already set up and ready to use. It’s now way more easy to add more Docker Services. A Docker Service is the parent of the actually Container.

Click on Create:

Go explore 🙂

Creating Ubuntu Docker VM in Azure

Mission goals:

– use a Linux VM in Azure

– install Docker

– connect via SSH

– install and run an open source system called Staytus

It should be straightforward, but this article is meant to record any ‘quirks’ that might occur through this adventure. This is to make it easier for someone else trying to do the same.

Prerequisites:

– Azure user. Create for free => https://azure.microsoft.com/en-us/free/

If you already have a MSDN sub then you should have some credits available. https://azure.microsoft.com/en-us/pricing/member-offers/msdn-benefits-details/

Ok, I will be short and to the point. Less words more action.

Goto https://azuremarketplace.microsoft.com/en-us/marketplace/apps/CanonicalandMSOpenTech.DockerOnUbuntuServer1404LTS

and start your Linux VM. Usually, this process is painless, and just works.

The result should look like something like this:

image001

Ok, that means that we have a Docker installation in Ubuntu on Azure with the address docker-ubuntu-4ivk4ppp.cloudapp.net

Updated Mission goals:
– use a Linux VM in Azure – OK
– install Docker – OK
– connect via SSH
– install and run an open source system called Staytus

Next, we need to connect to Ubuntu somehow. If you are running Windows 10 I recommend to try out installing Ubuntu ‘natively’ http://www.windowscentral.com/how-install-bash-shell-command-line-windows-10 because it’s fun 🙂

Or just use your Git Bash: ssh <username>@<ip>

     ssh  garg@docker-ubuntu-4ivk4ppp.cloudapp.net

and login.

If you get any password problems, try resetting it in Azure:

image002

If you were successfully you should get this:

image003

Hurray. It also shows that the latest Docker is installed.

Updated Mission goals:
– use a Linux VM in Azure – OK
– install Docker – OK
– connect via SSH – OK
– install and run an open source system called Staytus

Next, we are going to install a fork of Staytus => https://github.com/galexrt/staytus

mkdir git
cd git
git clone https://github.com/galexrt/staytus.git
cd staytus

This fork has a docker-compose.yml that split staytus and its database into two containers instead of the original repository running everything in one container (which is not “best practice” for containerization). Let’s start it!

docker-compose up

This command uses the default docker-compose.yml file.

You should start seeing something like this:

image004

image005

Looking at the running containers, it shows that everything is up and should be ready to use:

image006

It also shows that Staytus running on Port 80 on the Ubuntu, but on Port 5000 inside the Container.

Open it!

Get the IP from Azure Portal and open it in a browser:

image007

Great success! Ok, not really. We have to make some endpoints in Azure. The docker-compose file is already forwarding the container port 5000 to the Ubuntu server (Docker Host) on port 80. This means that in order to access the container we need to access the Port 80 on the Ubuntu server.

image008

Here I have added Port 80 and call it “Staytus”.

Let’s check the browser again:

image009

Updated Mission goals:
– use a Linux VM in Azure – OK
– install Docker – OK
– connect via SSH – OK
– install and run an open source system called Staytus – OK

Whoop whoop!

That was pretty cool. In less than 2 hours including creating this article Staytus is now running. I write slow:)

Breakpoint Bug in Visual Studio 2015

Today I discovered a peculiar bug in Visual Studio 2015. If you put in a very long string:

string strings = @”<very long string at least 80000 characters>”;

it does not stop on Breakpoints anymore:)

Visual Studio 2015 does not throw any errors. It just stops stopping on Breakpoints.

The solution was obviously to put the string in a another file and read it into the program, but still it was a rather fun bug to track down.