Installing a Ghost Blog with Docker on a Mac mini + Ubuntu
Always-fun trial and error! How to install a Ghost blog with Docker on an old 2014 Mac mini running Ubuntu 24.04 LTS (HTTPS + MySQL on a separate network).
In a previous post I introduced how to install Ghost with Docker on macOS, but it didn't work out that way. ^^;; Honestly, I struggled for days on end. Not being a developer, I was once again amazed at how narrow my knowledge is. After days of trial and error it finally worked, and I'm endlessly happy about it.
To deploy a Ghost blog reliably with HTTPS, Gmail SMTP, a separated DB and access control, I used Docker Compose. In particular, I configured SSL certificates to be managed automatically with the nginx-proxy + acme-companion combination.
Directory Structure
/var/www/blog/
├── docker-compose.yml
├── .env
└── data/
├── ghost/
└── mysql/- OS: Ubuntu 24.04.2 + Docker 28.3.2
1. Overall Structure
version: "3.9"
services:
nginx-proxy:
acme-companion:
mysql:
ghost:
networks:
proxy-tier:
ghost-internal:nginx-proxy: a reverse proxy handling HTTPS and domain-based routingacme-companion: issues and renews Let's Encrypt certificates automaticallymysql: Ghost's DB, for internal communication onlyghost: the Ghost blog servicenetworks: separates the network for the proxy from the network for internal DB traffic
2. nginx-proxy Configuration
nginx-proxy:
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- ./data/ghost:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/custom.conf:ro
environment:
- TZ=${TZ}
networks:
- proxy-tierjwilder/nginx-proxysets up the reverse proxy based on automatic container discovery.nginx.confis a custom configuration for hardening security.- Volumes are also defined for the certificate path and static resources.
- The Docker socket is mounted
ro(read-only) with security in mind.
3. acme-companion Configuration
acme-companion:
image: nginxproxy/acme-companion
container_name: acme-companion
depends_on:
- nginx-proxy
restart: always
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy
- DEFAULT_EMAIL=${GMAIL_USER}
- TZ=${TZ}
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./certs:/etc/nginx/certs
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
networks:
- proxy-tier- The
NGINX_PROXY_CONTAINERenvironment variable is required; it's what links it to the nginx-proxy container. - The email for certificate issuance is the Gmail address defined in the
.envfile. - The directories shared with nginx must be mounted identically for certificates to work.
4. MySQL Configuration (Internal Only)
mysql:
image: mysql:8.0.42
container_name: ghost-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
TZ: ${TZ}
volumes:
- ./data/mysql:/var/lib/mysql
networks:
- ghost-internal- An internal DB accessible only from Ghost.
- It's connected only to the
ghost-internalnetwork, blocking external exposure. - Passwords and DB info are managed in the
.envfile.
5. Ghost Blog Service Configuration
ghost:
image: ghost:5
container_name: ${BLOG_CONTAINER_NAME}
restart: always
depends_on:
- mysql
environment:
url: https://${DOMAIN}
database__client: mysql
database__connection__host: mysql
database__connection__user: ${MYSQL_USER}
database__connection__password: ${MYSQL_PASSWORD}
database__connection__database: ${MYSQL_DATABASE}
mail__transport: SMTP
mail__options__service: Gmail
mail__options__auth__user: ${GMAIL_USER}
mail__options__auth__pass: ${GMAIL_PASS}
mail__from: "'mango' <${GMAIL_USER}>"
TZ: ${TZ}
VIRTUAL_HOST: ${DOMAIN}
LETSENCRYPT_HOST: ${DOMAIN}
LETSENCRYPT_EMAIL: ${GMAIL_USER}
volumes:
- ./data/ghost:/var/lib/ghost/content
networks:
- proxy-tier
- ghost-internalurl: the address Ghost recognizes as its own. Set tohttps://since SSL is applied.- DB connection info and SMTP settings are all managed in
.env. VIRTUAL_HOST,LETSENCRYPT_HOSTandLETSENCRYPT_EMAILare keys recognized by nginx-proxy + acme-companion.- A
client_max_body_sizesetting was also applied separately in nginx to prevent file upload problems.
6. Network Configuration
networks:
proxy-tier:
ghost-internal:
internal: trueproxy-tier: a network that can receive outside requestsghost-internal: an internal network for the DB only (internal: trueblocks external traffic)
✍️ Conclusion
This docker-compose.yml satisfies the following:
- Automatic HTTPS (Let's Encrypt)
- Separated blog and DB networks
- Mail sending via Gmail SMTP
- Custom nginx security settings (
nginx.conf) - Access control for the Ghost admin page (IP restriction settings)
- Passwords and domain managed safely through
.env-based settings
The Full docker-compose.yml
version: "3.9"
services:
nginx-proxy:
networks:
- proxy-tier
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- ./data/ghost:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/custom.conf:ro
environment:
- TZ=${TZ}
acme-companion:
networks:
- proxy-tier
image: nginxproxy/acme-companion
container_name: acme-companion
depends_on:
- nginx-proxy
restart: always
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy # 👈 required
- DEFAULT_EMAIL=${GMAIL_USER}
- TZ=${TZ}
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./certs:/etc/nginx/certs
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
mysql:
networks:
- ghost-internal # not exposed externally
image: mysql:8.0.42
container_name: ghost-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
TZ: ${TZ}
volumes:
- ./data/mysql:/var/lib/mysql
ghost:
networks:
- proxy-tier # for outside access
- ghost-internal # for internal DB access
image: ghost:5
container_name: ${BLOG_CONTAINER_NAME}
restart: always
depends_on:
- mysql
environment:
url: https://${DOMAIN}
database__client: mysql
database__connection__host: mysql
database__connection__user: ${MYSQL_USER}
database__connection__password: ${MYSQL_PASSWORD}
database__connection__database: ${MYSQL_DATABASE}
mail__transport: SMTP
mail__options__service: Gmail
mail__options__auth__user: ${GMAIL_USER}
mail__options__auth__pass: ${GMAIL_PASS}
mail__from: "'mango' <${GMAIL_USER}>"
TZ: ${TZ}
VIRTUAL_HOST: ${DOMAIN}
LETSENCRYPT_HOST: ${DOMAIN}
LETSENCRYPT_EMAIL: ${GMAIL_USER}
volumes:
- ./data/ghost:/var/lib/ghost/content
networks:
proxy-tier:
ghost-internal:
internal: trueAdditional Security Settings
✅ 1. Recommended Owner: The Current User, or a User Docker Can Access
sudo chown -R $USER:$USER /var/www/blog$USERis the currently logged-in user- Ghost and MySQL need owner permissions to read and write files
✅ 2. Recommended Permissions (Directories and Files)
📁 Directories: 755
find /var/www/blog -type d -exec chmod 755 {} \;- Meaning: owner
rwx, group/othersrx(read + execute)
📄 Files: 644
find /var/www/blog -type f -exec chmod 644 {} \;- Meaning: owner
rw, group/othersr(read only)
🔒 Exceptions: the .env File, SMTP Passwords, etc.
Since .env contains passwords, to tighten security:
chmod 600 /var/www/blog/.env- Only the owner can read and write