Deploy ghost with Docker

Deploy ghost with Docker

For this article I am choosing Ubuntu 20.04. & Make sure docker is installed in your system. You can find docker & docker-compose installation guide here >

Login to your server via ssh

[email protected]

Now create a folder to contain the docker-compose.yaml & docker volumes.


now create a file called docker-compose.yaml into the folder you have just created

nano docker-compose.yaml

& paste the following

version: '3'
    image: ghost:latest
    restart: always
      - 10000:2368
      - ./content:/var/lib/ghost/content
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: specifypasswordhere
      database__connection__database: yourdomain_production
    container_name: yourdomain.com_db
    image: mysql:latest
    restart: always
      MYSQL_ROOT_PASSWORD: specify-password-here
    command: --default-authentication-plugin=mysql_native_password
      - ./data:/var/lib/mysql

Note: its good practice when you use custom port then it should start from 10000… eg. 10000 10001 etc

now save the file & run docker-compose up -d to start the stack. It should start just fine

Now configure the nginx server block

sudo nano /etc/nginx/sites/available/

& past the following & Update the port same as your docker container

server {
  listen 80;
  listen [::]:80;
  location / { return 301$request_uri; }
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  ssl_protocols TLSv1.2;
  ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;

  ssl_certificate /etc/ssl/$domain/cert.pem; #define your ssl cert path
  ssl_certificate_key /etc/ssl/$domain/key.pem; #define your private key path

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass; #define the port as your container


save the file & link it to sites-enabled

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

check the nginx configuration

sudo nginx -t

restart nginx

sudo systemctl restart nginx

now your blog should be up & running. To add a new ghost instance repeat the process

If you prefer No-Code solution to deploy ghost then checkout

Spookey! - Managed Ghost Publication Specially for NoCode Lovers
You've successfully subscribed to Visioun Updates.
Great! Next, complete checkout for full access to Visioun Updates.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.