FOSSFEEDWhere activity matters more than stars. Discover Fire Pit Noted Submit a project
← All articles

How to Self-Host Ghost Using Docker and Portainer

Deploy your own Ghost blog with Docker Compose and Portainer. A beginner-friendly guide to getting Ghost and MySQL running on your homelab.

You've chosen your hardware, learned the basics of self-hosting, and installed Docker and Portainer. Now it's time to put everything to work by launching your first website.

In this guide, I'll show you how to install Ghost using Docker Compose through Portainer. We'll start by getting it running on your local network. Once everything works, you can move on to connecting a domain and making your site accessible through Cloudflare.

What You'll Need to Get Started #

  • A computer or server running Debian
  • Docker and Docker Compose installed
  • Portainer installed and running
  • At least 2GB of RAM and sufficient available storage
  • Access to your server's local IP address

If you plan to make your Ghost website publicly accessible later, you'll also need a domain name. We'll cover that separately using Cloudflare Tunnel.

Choosing Hardware to Self-Host Your Website #

Ghost doesn't require a powerful server to get started. A refurbished mini PC, an older desktop, or a small virtual machine can handle a personal blog without much trouble.

I'd recommend starting with at least 2GB of RAM and around 30–50GB of storage for a small website. More memory and storage will give you room for additional applications, images, backups, and future growth.

When I originally started running Noted, I used an Intel NUC with Proxmox and allocated a small virtual machine to Ghost. It was a great way to learn, and it showed me that running a website doesn't necessarily require expensive hardware.

If you're starting from scratch, I'd look at a used Lenovo ThinkCentre, Dell OptiPlex Micro, HP EliteDesk Mini, or a modern low-power mini PC.

Whatever hardware you choose, make sure you have enough space for your database and uploaded content to grow.

Choosing an Operating System #

I'll be using Debian for this tutorial because it's a stable, reliable choice for running Docker. Ubuntu Server is another popular option, but some installation commands differ between distributions.

If you've been following the previous lessons, you should already have Debian, Docker, and Portainer installed and ready to use.

For this guide, we'll manage everything through Portainer's web interface.

Before We Install Ghost #

You should already have Docker and Portainer installed from the previous lesson. If you skipped that part, follow my Docker and Portainer installation guide before continuing.

Open Portainer in your browser using your server's IP address and port 9443.

For example:

https://192.168.1.5:9443

Once you've logged in, select your local Docker environment. We'll use Portainer's Stacks feature to deploy Ghost and its database together.

Install Ghost Using Docker Compose and Portainer #

Now for the fun part. We're going to install Ghost using Portainer's built-in Stacks feature.

A stack is simply a group of containers managed together through a Docker Compose configuration. In our case, we'll use one container for Ghost and another for its MySQL database.

Open Portainer, select your local environment, and click Stacks in the sidebar.

Click Add stack, give it the name ghost, and select the Web editor.

Copy the Docker Compose configuration below into the editor.

services:
  ghost:
    image: ghost:6-alpine
    restart: unless-stopped
    ports:
      - "2368:2368"
    environment:
      url: http://192.168.1.5:2368
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: CHANGE_ME_GHOST_PASSWORD
      database__connection__database: ghost
    volumes:
      - ghost_content:/var/lib/ghost/content
    depends_on:
      db:
        condition: service_healthy

  db:
    image: mysql:8.0
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: CHANGE_ME_ROOT_PASSWORD
      MYSQL_DATABASE: ghost
      MYSQL_USER: ghost
      MYSQL_PASSWORD: CHANGE_ME_GHOST_PASSWORD
    volumes:
      - ghost_database:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysql -h 127.0.0.1 -u \"$$MYSQL_USER\" -p\"$$MYSQL_PASSWORD\" -e \"SELECT 1\" \"$$MYSQL_DATABASE\" >/dev/null 2>&1"]
      interval: 10s
      timeout: 5s
      retries: 20
      start_period: 30s

volumes:
  ghost_content:
  ghost_database:

Before You Deploy #

There are a few values you need to change before deploying the stack.

1. Your server IP address

Find 192.168.1.5 in the url setting and replace it with your server's local IP address.

For example, if your server uses 192.168.1.100, your Ghost URL would be:

http://192.168.1.100:2368

2. Your database password

Replace both occurrences of CHANGE_ME_GHOST_PASSWORD with the same strong, unique password. These values must match because Ghost uses this password to connect to MySQL.

3. Your MySQL root password

Replace CHANGE_ME_ROOT_PASSWORD with a different strong password. Ghost doesn't need to use the database root account.

Once you've updated those values, scroll down and click Deploy the stack.

Portainer will pull the required images and create the Ghost and MySQL containers. MySQL may need a little time to initialize on the first launch.

You can check the containers and their logs from Portainer to see how the installation is progressing.

This stack creates persistent Docker volumes for Ghost's content and MySQL database. Your data won't disappear simply because a container is recreated, although you should still maintain backups.

Important: This is a basic local Ghost deployment. It doesn't include every service available in Ghost's newer official Docker setup, such as the additional components for self-hosted analytics and ActivityPub. You can explore those later through the official Ghost Docker project.

Open Your New Ghost Blog #

Once both containers are running, open your browser and navigate to the IP address you configured earlier.

For example:

http://192.168.1.5:2368

If everything went correctly, you'll see your new Ghost website.

To create your administrator account, add /ghost/ to the end of the URL:

http://192.168.1.5:2368/ghost/

Follow the setup instructions to create your account and give your publication a name.

Security note: This local installation uses HTTP, so traffic between your browser and Ghost isn't encrypted. Only use this setup on a trusted local network for testing. Before publishing your website or using it regularly, configure your public domain with HTTPS. Avoid reusing an important password while testing over HTTP.

You can now explore Ghost, create a few posts, and get familiar with the dashboard.

Keep in mind that this installation is only intended for testing on your trusted local network. Before making it publicly accessible, you'll need a domain name, HTTPS, and a properly configured reverse proxy or tunnel.

Once you configure your public domain, you'll also need to change Ghost's url environment variable to the final HTTPS address and redeploy the stack.

Don't expose the MySQL database to the internet. It only needs to communicate with Ghost through Docker's internal network.

Don't Forget About Backups #

Before you start publishing regularly, make sure you have a backup plan.

Ghost stores important information in two places: the MySQL database and its content directory.

The database contains your posts and settings, while the content directory holds uploaded images, themes, and other files.

Both need to be backed up.

Docker volumes keep your data persistent, but they aren't backups. If a drive fails or data becomes corrupted, those volumes may be lost.

I recommend creating regular database backups and keeping a separate copy of your Ghost content. Store those backups somewhere outside the server and periodically test that you can restore them.

Ghost also provides export tools in its admin dashboard, which can be useful for preserving your publication content. However, an export shouldn't replace a complete backup of your database and files.

A little preparation now can save you a lot of headaches later.

Want to Make Your Ghost Blog Public? #

Now that Ghost is running locally, you might be wondering how to access it from outside your home.

One option is Cloudflare Tunnel, which allows you to connect your website to a domain without forwarding ports directly to your home network.

I've written a separate guide covering the process if you want to take things further.

Read: Set Up Your Domain Using Cloudflare Tunnels and Zero Trust

You've Built Your First Self-Hosted Website #

If you've followed this course from the beginning, you've come a long way.

You started by choosing hardware and learning how self-hosting works. Then you installed Docker and Portainer, and now you have a working Ghost website running on your own server.

There's still plenty to learn, but you now have a foundation to build on.

Spend some time exploring Ghost and getting comfortable with your new setup. Once you're ready, you can look into custom domains, HTTPS, automated backups, and other applications to host alongside your blog.

And if you're looking for something new to self-host, you'll find plenty of ideas right here on Noted.

Comments 0

Join the conversation.

Write a comment

No comments yet. Be the first to comment.

Leave a comment

Anonymous comments are reviewed before publication. Sign in to comment as a member.

Navigation