Skip to content

Ghost · deploy guide

Deploy Ghost on a VPS with Docker Compose

Self-host Ghost on a Bashrack VPS with persistent volumes and Caddy HTTPS. You manage the server, updates and backups.

about 30 minutes of hands-on time

Who it's for

Customers comfortable managing a Linux server who want their own Ghost instance.

You'll need

  • An approved Bashrack account; review current VPS pricing and availability before adding funds
  • An Ubuntu VPS with sudo access and Docker Engine + Compose
  • A domain pointing to your VPS and access to its DNS records

Steps

  1. step 1

    Prepare a VPS and DNS

    Use an Ubuntu VPS with root or sudo access. This guide runs Docker Compose on your VPS; it does not use the managed Web Hosting source picker. Point your domain A record at the VPS public IPv4. You manage updates and backups.

    bash
    mkdir -p ~/ghost
    cd ~/ghost
    umask 077
    printf "DOMAIN=ghost.example.com\nTZ=UTC\n" > .env
    printf "DB_PASSWORD=%s\nDB_ROOT_PASSWORD=%s\n" "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" >> .env
  2. step 2

    Install Docker Engine

    Install Docker Engine and its Compose plugin using the official Docker Ubuntu instructions linked below. Confirm Docker is running before continuing.

    bash
    sudo docker version
    sudo docker compose version
  3. step 3

    Save compose.yaml

    Save this configuration as compose.yaml in the directory created above. Edit DOMAIN in .env to your real domain before deployment. Only Caddy exposes public ports. Never commit .env or share its contents.

    yaml
    services:
      app:
        image: ghost:6
        restart: unless-stopped
        environment:
          url: https://${DOMAIN}
          database__client: mysql
          database__connection__host: db
          database__connection__user: ghost
          database__connection__password: ${DB_PASSWORD:?Set DB_PASSWORD in .env}
          database__connection__database: ghost
        depends_on:
          db:
            condition: service_healthy
        volumes:
          - app_data:/var/lib/ghost/content
      caddy:
        image: caddy:2
        restart: unless-stopped
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - ./Caddyfile:/etc/caddy/Caddyfile:ro
          - caddy_data:/data
          - caddy_config:/config
      db:
        image: mysql:8.0
        restart: unless-stopped
        environment:
          MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:?Set DB_ROOT_PASSWORD in .env}
          MYSQL_DATABASE: ghost
          MYSQL_USER: ghost
          MYSQL_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env}
        volumes:
          - db_data:/var/lib/mysql
        healthcheck:
          test: ["CMD-SHELL", "mysqladmin ping -h localhost --silent"]
          interval: 10s
          timeout: 5s
          retries: 12
    volumes:
      app_data:
      caddy_data:
      caddy_config:
      db_data:
    
  4. step 4

    Configure HTTPS

    Save this as Caddyfile, replacing ghost.example.com with the same domain used in .env. Allow inbound TCP 80 and 443 in your VPS firewall, while preserving your SSH access. Do not expose the app or database port directly.

    text
    ghost.example.com {
      reverse_proxy app:2368
    }
  5. step 5

    Validate and start

    Run these commands from the directory containing compose.yaml. The first command validates configuration without printing substituted secrets. Inspect service health locally; do not paste logs containing credentials into support messages.

    bash
    sudo docker compose config --quiet
    sudo docker compose up -d
    sudo docker compose ps
  6. step 6

    Finish setup and back up

    Open your HTTPS domain and immediately create the Ghost owner account at /ghost. If setup fails, check DNS, firewall and container health before retrying. Back up persistent data before upgrading; restarting or recreating the container does not replace a tested backup. Never run docker compose down --volumes unless you intend to erase the data.

Security and upkeep

  • Create the owner account before sharing the URL.
  • Back up persistent app data and database dumps.
  • Review upstream release notes and test upgrades before changing image versions.
  • Keep .env private. Do not expose database ports.
  • Newsletter delivery needs a separately configured supported email service; this basic web deployment does not configure email, analytics or other integrations.

Official documentation