In this post we will take the solution we now have working from our post here and host it in a cloud provider, in my case I will be using Microsoft Azure, but this can be just about any cloud provider, in fact if you go to Docker Cloud, you can see a few listed there
Now, I was going to do this using Docker Cloud but a good mate of mine Bart Tubalinal, who is a Solutions Architect at Docker suggested that in order to really learn the ins and outs of Docker, I should stand up my own VM and command line my way to hosting my solution. The premise being that I would be issuing al the commands so I would know more that just having the browser telling me that it is “working on it”. Now that’s not a knock on the browser GUI, infact, I am going to use it for my next nodes just to see how it works, but I do feel better that I understand more about whats is going on behinds the scenes.
In this post, which will be short, as I will be pointing to some existing guidance along the way and calling out one or two gotchas, everything as in Docker Land is very simple and straight forward.
Setting up your Linux VM in Azure
Yes, this is your first step and for me that meant logging into https://portal.azure.com and creating a New Virtual Machine of Type Ubuntu Linux 16.04.
and go through the configuration steps outlined below
and select the type of VM Size you want
and then in the next options you are basically going to ensure that you:
- Get a Public Static IP Address and
- Create a new or Join into an Availability Set (this ensures redundancy between your VMs for high availability)
Once you have configured all your parameters, click OK and wait for your VM to be spun up.
Configure the Networking and DNS for the newly created Ubuntu Box
So now that we have our box set up, we will need to make some changes; the first of which is to open the Port that we will be exposing our Web.API through and if you remember from our Docker-Compose.yml file, that was on Port 8000
So we need to click into ‘Network Interfaces’ there on the left and on the IP Address that is provided… basically
Network Interfaces >> Network Security Group(NSG) >> Click to Edit the NSG >> Click on Network Interface (singular) >> Click on Inbound Security Rules >> Add
and now you will have two rules, one for SSH and the other for the HTTP port 8000 for the endpoint
Next we will add a DNS Name to it for two reasons, one we an address it by name when we SSH into our box and two [more importantly] we can use this name in the browser when we are accessing our Web.API, to to that we need to click into the IP address from the Overview screen of our VM
and now we have a DNS name to where we had none above and now we can SSH into our BOX.
and then Update and Upgrade your Ubuntu Box by issuing apt-get update and upgrade commands
Installing Docker CE on Ubuntu
once you have run those commands and your system is updates, then the guidance from Docker Docs will help you along the way. Pick up from after the update command.
and follow all the way to the end. Once all the steps are done, we need to test to see if Docker is working, we do that by pulling and building out a hello-world example off DockerHub
and if everything is OK, we should get a Hello From Docker as you see above called out.
Install Docker Compose
So, as I mentioned in the post here, when you install Docker on Mac or Windows you get Docker Compose installed with it, but on a Linux box, you need to do it manually. Now the guidance in the Docker Docs “IF” you run them WILL NOT give you the most up to date version of Docker-Compose and as such IF you use a docker-compose file with [at the time of this writing] a Version 3, it will fail. So, to remedy this there is guidance here that will show you how to install ALWAYS the Latest Version of Docker Compose, it will ask you as part of it to find out the current version of Docker Compose and to do that see here. So do that and we will continue.
Installing the Web.API solution into the Cloud
This is very simple, the steps are
- Pull down the my Custom Image from Docker Hub
- Then we need to make a Directory to hold our Docker-Compose.YML file
- Next we will copy the Docker Compose YML file from the local box to this new Ubuntu Box by the command
scp docker-compose.yml username@fqdn_of_linuxbox:~/name_of_directory_created_above
and basically this gets you back to Step #5 in this post again. The only KEY difference is that you can hit this from the Internet now and you have successfully hosted your Docker Solution in the Cloud. Open up Chrome or Fiddler or Postman
So, good right? After this, you should be stoked as I was to see the power of Docker in action. Ill do a proper summary in the beginning of the Series summary right here.