Ghost is a publishing platform built for newsletters and membership blogs, and running it on your own server gives you full control over data, themes, and costs. The officially supported production setup pairs Ghost with MySQL 8, and Docker Compose is the cleanest way to install Ghost CMS with Docker and MySQL: two containers, one file, and named volumes you can back up. This guide walks you through the whole process on a VPS, from the compose file to HTTPS and backups. If you want a ghost self-hosted blog VPS setup you fully control, this guide walks through every step.
What You Need Before Installing Ghost
A small VPS is enough for a typical Ghost blog. Aim for at least 1 vCPU and 2 GB of RAM, since Ghost runs on Node.js and MySQL 8 needs its own share of memory. Ubuntu 22.04 or 24.04 works well, and you need root or sudo access. Entry-level VPS plans that fit this start at a few dollars a month, but check official pricing from your provider because plans change often.
You also need three things ready before you touch Docker:
- A domain name with an A record pointing at your server IP. You can test with the IP first, but HTTPS and the final configuration need the real domain.
- Docker Engine and the Compose plugin. Verify with
docker compose version; if it prints a version number, you are ready. - Ports 80 and 443 open in your firewall for the reverse proxy you will add later.
Install Ghost CMS with Docker and MySQL: the Compose File
This Ghost Docker Compose setup keeps both services in a single file, which makes updates and backups straightforward. Create a project directory and move into it:
mkdir -p ~/ghost && cd ~/ghost
First generate strong passwords and store them in a .env file so no secret is hardcoded in the compose file:
echo "MYSQL_ROOT_PASSWORD=$(openssl rand -hex 16)" > .env
echo "GHOST_DB_PASSWORD=$(openssl rand -hex 16)" >> .env
chmod 600 .env
Now create docker-compose.yml:
services:
ghost:
image: ghost:5-alpine
restart: unless-stopped
ports:
- "2368:2368"
environment:
url: https://blog.example.com
database__client: mysql
database__connection__host: db
database__connection__user: ghost
database__connection__password: ${GHOST_DB_PASSWORD}
database__connection__database: ghost
volumes:
- ghost-content:/var/lib/ghost/content
db:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ghost
MYSQL_USER: ghost
MYSQL_PASSWORD: ${GHOST_DB_PASSWORD}
volumes:
- mysql-data:/var/lib/mysql
volumes:
ghost-content:
mysql-data:
A few choices here are deliberate. Pinning ghost:5-alpine keeps updates predictable instead of pulling a surprise major version. The url variable must be the exact public address of your blog, including https://, because Ghost builds links and redirects from it. Both services write to named volumes, so your content and database survive container rebuilds.
Replace https://blog.example.com with your real domain before continuing.
Configure the Ghost MySQL 8 Database
Ghost 5 requires MySQL 8. The Ghost team does not support MariaDB, and SQLite is meant for local development only, so the db service above uses the official mysql:8.0 image. The environment variables create a dedicated ghost database and user on first start, which keeps Ghost isolated from anything else the database server might host.
There is nothing else to configure by hand. The credentials flow from .env into both containers, and the mysql-data volume holds the actual database files on the host. If you ever move servers, that volume plus a dump (covered below) is everything you need.
Start the Containers and Finish the Admin Setup
Bring the stack up:
docker compose up -d
docker compose ps
The first start takes a minute or two while MySQL initializes and Ghost runs its database migrations. Watch progress with docker compose logs -f ghost and wait for the line saying Ghost is running. Then open http://YOUR_SERVER_IP:2368/ghost in a browser. Ghost shows a welcome screen where you create the owner account. That account is the site admin, so use a strong password and an email address you actually monitor.
Once you log in, you land in the Ghost admin panel. Publish a test post, pick a theme, and confirm images upload correctly before you wire up the domain.
Put Your Ghost Self-Hosted Blog on a VPS Behind HTTPS
Leaving port 2368 open to the internet works, but a reverse proxy with TLS is the setup you want for a real site. Caddy is the shortest path because it fetches and renews Let’s Encrypt certificates on its own:
blog.example.com {
reverse_proxy localhost:2368
}
Point Caddy at that file, reload it, and your blog is served over HTTPS. If you prefer Nginx, proxy port 2368 and add certificates with Certbot; the result is the same.
One setting causes most of the headaches people report: the url variable in your compose file must match the public address exactly. If visitors reach the blog at https://blog.example.com but url still says http://YOUR_SERVER_IP:2368, Ghost issues redirect loops. Update the value, run docker compose up -d to recreate the container, and the loops stop.
Update and Back Up Your Ghost Docker Install
Updates are a two-command job. Pull the new image and recreate the container; the named volumes keep your data untouched:
docker compose pull ghost
docker compose up -d ghost
Check the version in the admin panel footer afterward. Read the Ghost release notes before jumping major versions, and keep a backup from right before the update, just in case. The same two-command rhythm runs most Docker self-hosting, whether the app is Ghost, n8n, or Vaultwarden.
Backups need two parts: the database and the content volume. Dump the database with:
docker compose exec db mysqldump -u ghost -p"$GHOST_DB_PASSWORD" ghost > ghost-backup.sql
Archive the content directory (themes, images, uploads) with:
docker run --rm -v ghost_ghost-content:/data -v $(pwd):/backup alpine
tar czf /backup/ghost-content.tar.gz -C /data .
Note the volume name is prefixed with the project directory name (ghost_ghost-content); check yours with docker volume ls. Copy both files off the server, and put the pair on a cron schedule so backups happen without you thinking about it.
Troubleshooting FAQ
The Ghost container keeps restarting. What should I check?
Run docker compose logs ghost and docker compose logs db. On a first boot the usual cause is Ghost starting before MySQL is ready; it settles on a retry. If it never settles, look for a wrong database password or a corrupted mysql-data volume.
I see a redirect loop after adding my domain.
The url environment variable does not match the address visitors use. Set it to the exact public URL with https://, recreate the container with docker compose up -d, and clear your browser cache before retesting.
Can I use MariaDB instead of MySQL 8?
Not safely. Ghost 5 officially requires MySQL 8, and the Ghost team does not test or support MariaDB. Stick with the mysql:8.0 image from the compose file above.
How much traffic can this setup handle?
That depends on your theme, caching, and VPS size rather than Ghost itself. A 2 GB VPS runs Ghost plus MySQL 8 comfortably for small to medium blogs; when response times climb, add a CDN or move to a larger plan instead of guessing.
How do member emails and newsletters work?
Ghost sends member invitations, sign-in links, and newsletters through SMTP or Mailgun. Configure mail in Ghost admin under Settings, then send yourself a test invite before announcing the blog.
Conclusion
You now have Ghost running in Docker with MySQL 8, served over HTTPS, with a backup routine you can automate. The natural next steps are choosing a theme, configuring mail so memberships work, and scheduling the backup commands above with cron. From here, publishing is just writing. Adding Uptime Kuma takes ten minutes more and tells you the moment the blog goes down.