How to install Ghost with Docker
The Docker image for Ghost is an unofficial community package maintained by people within the Ghost developer community.
Resources
Resources and downloads:
Install Docker Engine on Ubuntu
To get started with Docker Engine on Ubuntu, make sure you meet the prerequisites, and then follow the installation steps.
OS requirements
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
- Ubuntu Lunar 23.04
- Ubuntu Kinetic 22.10
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Focal 20.04 (LTS)
Docker Engine for Ubuntu is compatible with x86_64 (or amd64), armhf, arm64, s390x, and ppc64le (ppc64el) architectures.
Uninstall old versions
Before you can install Docker Engine, you must first make sure that any conflicting packages are uninstalled.
Distro maintainers provide an unofficial distributions of Docker packages in APT. You must uninstall these packages before you can install the official version of Docker Engine.
The unofficial packages to uninstall are:
docker.io
docker-compose
docker-doc
podman-docker
Moreover, Docker Engine depends on containerd
and runc
. Docker Engine bundles these dependencies as one bundle: containerd.io
. If you have installed the containerd
or runc
previously, uninstall them to avoid conflicts with the versions bundled with Docker Engine.
Run the following command to uninstall all conflicting packages:
$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
apt-get
might report that you have none of these packages installed.
Images, containers, volumes, and networks stored in /var/lib/docker/
aren't automatically removed when you uninstall Docker. If you want to start with a clean installation, and prefer to clean up any existing data, read the uninstall Docker Engine section.
Install using the Apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
- Set up Docker's Apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
- Install the Docker packages.LatestSpecific versionTo install the latest version, run:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Create docker-compose.yml
Example docker-compose.yml for ghost:
services:
ghost:
image: ghost:latest
restart: always
ports:
- "2368:2368"
depends_on:
- db
environment:
url: https://blog.devomkar.com
database__client: mysql
database__connection__host: db
database__connection__user: ghost
database__connection__password: ghostdbpass
database__connection__database: ghostdb
mail__transport: SMTP
mail__options__host: smtpout.secureserver.net
mail__options__port: 587
mail__options__auth__user: YOUR_EMAIL_HERE
mail__options__auth__pass: YOUR_PASSWORD_HERE
mail__from: YOUR_EMAIL_HERE
volumes:
- /home/ghost/content:/var/lib/ghost/content
db:
image: mariadb:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: ghost
MYSQL_PASSWORD: ghostdbpass
MYSQL_DATABASE: ghostdb
volumes:
- /home/ghost/mysql:/var/lib/mysql
I have used my Godaddy SMTP but you can go ahead with Mailgun or Amazon SES
sudo docker compose up -d
Nginx reverse proxy configuration
If you are using an Nginx reverse proxy setup, much like the one I've implemented in my HomeLab Proxmox setup, you will require a specific Nginx configuration.
server {
listen 80;
listen [::]:80
server_name blog.devomkar.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass "http://192.168.0.172:2368";
}
location ~ /\.ht {
deny all;
}
}
Stay tuned for more tricks up our sleeves, join the adventure, stay curious, and geek out with us.
Member discussion