Run Ghost with Docker
Docs: https://hub.docker.com/_/ghost/
The Hello World version
Connect to your Lightsail instance and create a path for the Ghost content. I created separate paths for each blog hosted on my Lightsail instance so they can be managed independently.
mkdir -p ~/websites/cronspam.org/content
Then launch the Docker image for Ghost. This will automatically pull the Docker image from Dockerhub:
docker run -d \
--name blog \
-e url=http://cronspam.org \
-p 80:2368 \
-v /home/ec2-user/websites/cronspam.org/content:/var/lib/ghost/content \
ghost:3
You can visit the new site at: http://cronspam.org
And the admin page is at /ghost
: http://cronspam.org/ghost/
WARNING: Go to the admin page ASAP to create the admin
account, until you do it's available for anyone to claim - the first visitor becomes the admin
!
Using docker-compose
First, install docker-compose
. It's always annoying that it's not part of the official Docker tools (yes, I know why, and it's still annoying).
# Install `docker-compose` from Docker
sudo curl -L \
https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) \
-o /usr/local/bin/docker-compose
# Fix the permissions
sudo chmod +x /usr/local/bin/docker-compose
# Verify it works
docker-compose version
Created a ~/websites/cronspam.org/cronspam.org.yaml
Docker compose file to configure the Docker container. I created a separate Docker compose file for each blog hosted on my Lightsail instance so they can be managed independently.
# By default, the Ghost image will use SQLite (and thus requires no separate database container)
version: '3.1'
services:
ghost_cronspam:
container_name: ghost_cronspam
image: ghost:3
restart: always
ports:
- 80:2368
volumes:
- /home/ec2-user/websites/cronspam.org/content:/var/lib/ghost/content
# See: https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables
environment:
url: http://cronspam.org
Run the compose file:
docker-compose -f ~/websites/cronspam.org/cronspam.org.yaml up --detach