Setting Up a Blog with Ghost, Caddy, and Docker
![Setting Up a Blog with Ghost, Caddy, and Docker](/content/images/size/w1200/2025/02/27748ce5-0cd7-4256-9dba-7486e46e3186.jpeg)
Setting up a blog with Ghost and using Caddy as a reverse proxy for automatic HTTPS is a super simple and secure way to get your blog online. With everything running in Docker.
Prerequisites
Before getting started, ensure you have:
- A VPS or any server with Docker and Docker Compose installed.
- Check out the official Docker documentation for installation help.
- A domain name pointed to your server's IP address.
- Basic familiarity with terminal commands.
Setting Up
I don't know why, but usually I created the follow structure on server to keep the website in one place.
Add the following content, replacing myblogdomain.com
with your domain name:
sudo mkdir -p /srv/myblogdomain.com/
cd /srv/myblogdomain.com/
Inside /srv/myblogdomain.com/
, create a Caddyfile
to set up the reverse proxy:
vim /srv/myblogdomain.com/Caddyfile
myblogdomain.com {
reverse_proxy blog:2368
}
Caddyfile
In the same directory, create a docker-compose.yml
file:
services:
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./caddy_data:/data
- ./Caddyfile:/etc/caddy/Caddyfile
blog:
image: ghost:5
restart: always
volumes:
- ./data/content:/var/lib/ghost/content
environment:
database__client: mysql
database__connection__host: database
database__connection__user: root
database__connection__password: <strong-password>
database__connection__database: ghost
url: https://myblogdomain.com
NODE_ENV: production
depends_on:
- database
database:
image: mysql:8.0
restart: always
volumes:
- ./db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: <strong-password>
MYSQL_DATABASE: ghost
MYSQL_USER: user
MYSQL_PASSWORD: <strong-password>
Note: Replace <strong-password>
with strong, secure passwords.
Additional Ghost Configuration
For more customization options, refer to the Ghost documentation.
1 - Start the Containers
Run the following command to start your blog:
docker compose up -d
2 - Check the logs:
Monitor logs to ensure everything is running good
docker compose logs -f
The -f
means "follow" with this you will see the live logs.
3 - Verify Containers
Use the docker ps command to check if all containers are up:
docker ps
you will see a output like
534136fa6112 ghost:5 "docker-entrypoint.s…" 23 hours ago Up 23 hours 2368/tcp myblogdomain-blog-1
43b3ce9bca1f caddy:2-alpine "caddy run --config …" 23 hours ago Up 19 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 443/udp, 2019/tcp myblogdomain-caddy-1
bf22abd3cb74 mysql:8.0 "docker-entrypoint.s…" 23 hours ago Up 23 hours 3306/tcp myblogdomain-mysql-1
docker ps output
Visit https://myblogdomain.com/ghost in your browser to finalize the Ghost setup. Once you’ve created your admin account and configured the basics, your blog is ready to go!
Enjoy building your blog and sharing your ideas with the world!