Dockerize Ghost Blog Site

When i started to blog, I want my site to looks clean and simple, easy to manage, free dependencies from relational database and allow me to write in Markdown, also without any heavy plugins that clogging your site. It is when I discover Ghost and used it as my blogging platform.

Ghost is a blogging platform written in Node.js that used SQLite as a back-end database. It has well documentation and easily to start with. I follow the instruction and here we are. After installed in a local PC, I am impressed. All of my blog use Ghost running in VPS since then, and no going back for other blogging platform.

So, i have running blog site, it is when i want to migrate to other VPS. I started to look easy solution to migrate over existing blog to my new VPS. Then i found Docker. Ghost has official Docker Hub image, that you can use to contain your blog.

I encourage you to learn Docker first to get a brief knowledge what we will do.

Now, we can start our learning.


First, you need to backup your existing blog. You can refer to our previous tutorial about How to backup Ghost blog.

Install Docker

You need to install followings:

  • Docker
  • Docker Compose

Please refer to official site to install Docker in your system:

Create Docker Compose file

We will create a Docker Compose file to manage our Ghost container. Create a file named docker-compose.yml and make a docker configuration inside it, below is working copy of docker-compose.yml of my site.

version: '3.5'services:  ghost:    container_name: ghost    image: ghost:latest    restart: always    ports:      - "3001:2368"    environment:      url:    volumes:      - ./app/content:/var/lib/ghost/content

See also  Laragon, the best alternate solution for XAMPP in Windows

Then, you need to run it with this command in the same directory with docker-compose.yml file:

docker-compose up -d

It will expose port 3001 in our host to access ghost container blog.

Create a Reverse Proxy

To access port 3001 in our host and expose it to public internet, you need to create a reverse proxy. In this case i use Nginx as my web server and create a reverse proxy config, as shown below.

# SSLredirectStart - HTTP to HTTPS Redirectserver {        listen 80;        listen [::]:80;        server_name;        return 301 https://$host$request_uri;}# SSLredirectEnd# WWWredirectStart - Force WWW or non-WWW redirectserver {        listen 443 ssl http2;        listen [::]:443 ssl http2;        server_name;        # WebinolySSLstart        ssl_certificate /etc/letsencrypt/live/;        ssl_certificate_key /etc/letsencrypt/live/;        ssl_stapling on;        ssl_stapling_verify on;        ssl_trusted_certificate /etc/letsencrypt/live/;        # WebinolySSLend        include common/headers-http.conf;        include common/headers-https.conf;        return 301 $scheme://$request_uri;}# WWWredirectEndserver {        listen 443 ssl http2;        listen [::]:443 ssl http2;        server_name;        # SSLstart        ssl_certificate /etc/letsencrypt/live/;        ssl_certificate_key /etc/letsencrypt/live/;        ssl_stapling on;        ssl_stapling_verify on;        ssl_trusted_certificate /etc/letsencrypt/live/;        # SSLend        access_log /var/log/nginx/ we_log;        error_log /var/log/nginx/;        location / {                proxy_set_header Host $host;                proxy_set_header X-Forwarded-Host $host;                proxy_set_header X-Forwarded-Server $host;                proxy_set_header X-Forwarded-Proto $scheme;                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                proxy_http_version 1.1;                proxy_set_header Upgrade $http_upgrade;                proxy_set_header Connection "upgrade";                proxy_redirect /;                proxy_redirect ws:// /api/socket;                proxy_pass;                proxy_connect_timeout 300;                proxy_send_timeout    300;                proxy_read_timeout    300;        }}

Updating Ghost Container

If there are any Ghost newer version, it is easy to upgrade to the latest Ghost version. Go to directory where you docker-compose.ymlfile exist. Then follow below instructions.

Stop our Ghost container.

docker-compose down

Pull latest Ghost image to our local server.

docker-compose pull

Start the Ghost container again.

See also  Building Simple RESTful API with Flask

docker-compose up -d

Well done. You have learned how to containerize your Ghost blog with easy step. If you have any question don’t hesitate to ask in comment.

See you!

Originally posted 2019-03-23 23:54:00.

About wahyuway

Check Also

Move Docker Toolbox images location in Windows 10

I have been heavily using Docker recently to help me develop under different environment. And …

Leave a Reply