Self-Hosted Ghost Blog on GCP FREE Tier

This weekend I got bored and decided to give GCP (Google Cloud Platform) Free Tier a try. In my experience the best way to learn things is doing it, and having a good purpose. I’ve been reflecting my writng habit and relaized I probably don’t write enough to share all the learnings. So this is it, I’ve decided to host my own Ghost installation with GCP Free Tier. Why? Becuase I like free stuff, to me a meal taste better if it’s free!

Setting Up a Free Compute Engine

Here are the offerings

Since Ghost remommended installtion on Ubuntu 16.04 LTS I figured it might be a good idea to follow that advice. So the first step is getting a free Google Compute Engine

Sure, let’s launch a free VM instance within these limitations.

 Please remember to increase the Boot disk size from 10 to 30. I mean, why not? It’s free! Another important thing to note is to avoid creating VM in us-east4 as it's in North Virginia, and NOT FREE. I learned this after the blog was launhed so I had to recreat another one. With the Docker installation I was able to get a new one up in 10 minutes.

Wait for it to finish until you see this

Now select Open in browser window and get rocking!

Installing Ghost on Free Compute Engine

I opted in for Docker installation because it’s easier and I can’t go back to the days of installing all dependencies one by one to make sure things are running well.

DigitalOcean has a nice post about this already so I’m just going to power through tis part. These are the 4 commands absolutely needed.

$ curl -fsSL | sudo apt-key add - 
$ sudo add-apt-repository "deb [arch=amd64] 
$(lsb_release -cs) stable" 
$ sudo apt-get update $ sudo apt-get install -y docker-ce

Now run this
 $ sudo docker run -d -p 80:2368 --name ghost -e url="https://<your blog domanin>" -v ~/ghost:/var /lib/ghost/content ghost

Few important things

  • Assuming you have a domain already, if not. I personally use Namecheap. Oh how much I wish it’s NameFree instead. Set the domain name with Docker environment variable using -e
  • Mount the blog volume to your host filesystem -v ~/ghost:/var /lib/ghost/content ghost. This is optional but I'd like to see what is Ghost doing in the container.

Alright, you may see it installed locally on port 80. Do a curl localhost on the host OS (VM instance) to see it.

Wait! Why am I seeing this
 Moved Permanently. Redirecting to https://localhost/

It’s because Ghost assumes your installation is on the domain name you provided. If you don’t have a domain name read off hand and is dying to see something happens. Remove -e parameter from the docker run command to install on localhost instead.

Are you still with me?

Setting Up a DNS Record

Okay, assuming you have a domain name already now is a good time to point your domain name to your Ghost installation. Go back to the Google Compute Engine to find out the External IP is easy, and you probably saw it too.

Yeah, the red box with the external IP is what you need. Now let’s do DNS. I will use my Namecheap console as an example.

The second red box for value should be the external IP you see from GCP. Wait 20 minutes (or longer) for it to propogate.


This looks so exciting! Oh how the hell am I going to add new posts so it isn’t a static page? I had this confusion as well. It turned out we have to use a client to connect to the Ghost installation to create the first account so you can start wring cool stuff and be awesome.

Download the client

  1. Your blog domain
  2. Your email address (don’t worry, you won’t be getting emails because we haven’t set up SMTP on Ghost, yet)
  3. Possowrd of your desire

If you are seeing this as a result. You are doing something right. Congratulations!

Enjoy blogging with Ghost!

Wait! What about SSL/TLS, Load Balancing and Backup?

Good one if are thinking about these kind of things. I think that deserve a sperate post on it’s own. I’m happy to do another write up on how to

  • Get a free SSL/TLS certificate from Let's Encrypt
  • Install the certificate to do SSL/TLS termination on GCP Load Balancer

If you have any questions in the meantime, hit me up on Twitter


Originally published at on September 10, 2017.