Ghost CMS with Docker and Nginx Setup on Ubuntu 24.04

By Raman Kumar

Share:

Updated on Mar 17, 2026

Ghost CMS with Docker and Nginx Setup on Ubuntu 24.04

Learn how to set up Ghost CMS with Docker, MySQL, and Nginx on Ubuntu. A secure and scalable configuration with HTTPS, backups, and production-ready best practices.

Introduction

Ghost is a fast, modern publishing platform, and Docker allows us to run it in a clean, scalable, and predictable environment. In this guide, we set up Ghost with Docker Compose, connect it to MySQL, and configure Nginx with SSL for production use.

Prerequisites

Before we begin, ensure we have the following:

  • An Ubuntu 24.04 on dedicated server or KVM VPS.
  • Basic Linux Command Line Knowledge.
  • A domain name pointing A DNS record to server IP.

Step 1: Install Docker (Latest Method)

Install Docker using the official repository.

Add Docker's official GPG key:

sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the repository to Apt sources:

sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

Install the Docker packages.

sudo apt install -y docker-ce

Verify:

docker --version
docker compose version

Enable Docker:

systemctl enable docker
systemctl start docker

Step 2: Create Project Structure

We will create separate directory for ghost cms deployment.

mkdir -p /var/www/ghost
cd /var/www/ghost

Step 3: Create Docker Compose File

Create file:

nano docker-compose.yml

Paste:

services:
  ghost:
    image: ghost:latest
    container_name: ghost_app
    restart: unless-stopped
    depends_on:
      - db
    environment:
      url: https://yourdomain.com
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: strongpassword
      database__connection__database: ghost_db
      NODE_ENV: production
    volumes:
      - ./ghost_content:/var/lib/ghost/content
    ports:
      - "127.0.0.1:2368:2368"

  db:
    image: mysql:8.0
    container_name: ghost_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: ghost_db
      MYSQL_USER: ghost
      MYSQL_PASSWORD: strongpassword
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - ./db_data:/var/lib/mysql

Start Docker services

docker compose up -d

Check status:

docker compose ps

Ghost is now running internally at:

http://127.0.0.1:2368

Step 4: Configure Nginx Reverse Proxy

Install Nginx:

sudo apt install -y nginx

Create config:

sudo nano /etc/nginx/sites-available/ghost

Add:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:2368;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Enable site:

ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx

Firewall Configuration

ufw allow OpenSSH
ufw allow 'Nginx Full'
ufw enable

Step 5: Enable SSL (Let’s Encrypt)

Install Certbot:

apt install -y certbot python3-certbot-nginx

Run:

certbot --nginx -d yourdomain.com -d www.yourdomain.com

Auto-renew is already configured:

systemctl status certbot.timer

Step 6: Access Ghost Admin

Open:

https://yourdomain.com/ghost

Ghost Admin Setup Hostperl

Complete setup:

  • Create admin user
  • Configure publication
  • Set branding

Step 7: Backup Strategy (Production Essential)

Backup content:

tar -czvf ghost_content_backup.tar.gz ghost_content

Backup database:

docker exec ghost_db mysqldump -u ghost -pstrongpassword ghost_db > db_backup.sql

Schedule via cron for automation.

Step 8: Updating Ghost Safely

docker compose pull
docker compose up -d

Never update without backup unless you enjoy rebuilding everything from scratch.

Enable Monitoring

docker logs -f ghost_app

Summary

We have seen how to install GhostCMS on Ubuntu 24.04 using Docker.This guide presents a structured approach to setting up Ghost CMS using Docker in a production-ready environment. It covers the complete process from installing Docker using the official repository to configuring a containerized Ghost application with a MySQL database.

The setup includes creating a clean project structure, defining services using Docker Compose, and running Ghost in a secure and isolated environment. Nginx is configured as a reverse proxy to manage incoming traffic efficiently, followed by enabling HTTPS using Let’s Encrypt for secure communication.