So, it's come to a point where I need to separate out my blogs into their respective topics and document the results of my projects for sharing purposes. So, welcome to my first post on my tech blog which will provide a brief overview of Azure VMs, Docker and the Ghost blogging platform.
I've used the Ghost blogging platform previously (before it reached v1) and remembered how simple its interface is in terms of blog theming, markdown and content management so thought let's combine it with Docker to get it off the ground fast. So what will we be using?
VM Setup
The first thing to do is to spin up an instance of a Ubuntu Server on Azure, the process is fairly straightforward; select create a resource and search for Ubuntu Server 17.10 VM. Follow the steps through with the following in mind:
- Choose a machine that your credit covers
- When you get to configuring the IP, make sure it's set to static otherwise redirecting a domain to the blog is not going to be possible.
Why use a Ubuntu Server instead of MS Server 2016? Well, the Docker containers as a preference run on Linux so if a container does not have a Docker for Windows configuration, we can't use it. There also seems to be some issues with HyperV on Azure when it comes to virtualising a Linux box for Docker on Windows so we can't use Linux containers on Windows Server 2016. Bummer!
Right, once the machines up and running we need to ssh onto the machine. Grab a copy of Putty if you don't already have it. Open a command line terminal at its location and type...
putty.exe -ssh {username}@{machine ip address}
(Note if SSH is blocked on your machine you can run this from another vm)
You will then get prompted for your password after which you'll then be connected to your VM.
Docker Setup
The next step is to set up Docker which fortunately Digital Ocean has provided a nice guide. Right now we're only interested in step one and two which consist of the following commands:
Install Docker
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get update
$ apt-cache policy docker-ce
$ sudo apt-get install -y docker-ce
$ sudo systemctl status docker // Should indicate that Docker is installed
Configure Docker to bypass sudo
$ sudo usermod -aG docker ${USER} //Where user is your machine login
$ su - ${USER}
$ (Input password)
$ id -nG // will confirm that docker has been configured.
At this point I would also restart the VM to make sure the changes take effect. Good news - we are now ready to set up Ghost.
Installing Ghost
Fortunately for us, the Ghost team have already set up a Ghost container so let's pull it.
$ docker pull ghost // Will default to @latest
That's it, we have everything we need. All we need to do now is start the container with the following:
$ docker run -d --restart unless-stopped --name {choose a name} -p {choose a port}:2368 ghost
This will run the container as a background process (-d), it will restart until manually stopped (--restart unless-stopped), perfect for when the VM restarts. --name is how you will reference the container in Docker and the port (-p) is how you will access the blog e.g. http://localhost:{chosen port }.
Open the Port
The final step is to open access to the port in Azure. In the VMs menu, select networking and add a new inbound port rule. Set port range to the specific port you defined earlier and set priority to 100 and click OK.
Once Azure is done with that, you should now be able to access your blog through http://{VM ip}:{chosen port}. Nice!
You now have a Ghost blogging platform while your VM is running. To get to the blog manager just head to http://{VM ip}:{chosen port}/ghost which will get you to create an account. Following that, you can modify the content until your heart's content. Happy Blogging.
Comments