How to install Ghost in Docker

The recommended installation should be database-driven and simple. First, our data is persistent, and second, we don't want to mess with the command stream. Therefore, the instructions will be short and simple.


Prerequisites:

  • VPS + Domain
  • Docker with docker-compose
  • Nginx (all services and websites are exposed via proxy)

Files

  • docker-compose.yml
version: "3.3"
services:
  ghost:
    image: ghost:latest
    restart: always
    depends_on:
      - db
    ports:
      - 127.0.0.1:2368:2368
    environment:
      url: https://services.org.pl
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: pass1
      database__connection__database: ghostdb
    volumes:
      - /opt/docker-volumes/ghost/content:/var/lib/ghost/content
  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: pass1
      MYSQL_USER: ghost
      MYSQL_PASSWORD: pass1
      MYSQL_DATABASE: ghostdb
    volumes:
      - /opt/docker-volumes/ghost/mysql:/var/lib/mysql
  • services.org.pl.conf (nginx)
server {
    root /var/www/html;
    server_name services.org.pl;
    include /etc/nginx/snippets/proxy.conf;
    location / {
      proxy_pass http://127.0.0.1:2368;
    }


    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/services.org.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/services.org.pl/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = services.org.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;
    server_name services.org.pl;
    return 404; # managed by Certbot


}

Commands

  • Docker compose start
sudo docker-compose -f docker-compose.yml up -d
  • Reload nginx
sudo nginx -t && sudo nginx -s reload

To finish configuration goto https://services.org.pl/ghost

Show Comments
AbuseIPDB Contributor Badge LinkedIn Profile