Home How to Create Jekyll Local Development Server in Docker
Post
Cancel

How to Create Jekyll Local Development Server in Docker

What is Jekyll

Jekyll is a static site generator(SSC).It takes text written in your favorite markup language and uses layouts to create a static website. You can tweak the site’s look and feel, URLs, the data displayed on the page, and more.

Installing docker

Updating repo

1
sudo apt update 
1
sudo apt install docker.io

Installing docker-compose

1
sudo apt install docker-compose

Cloning jekyll theme

Jekyll has an extensive theme system that allows you to leverage community-maintained templates and styles to customize your site’s presentation. Jekyll themes specify plugins and package up assets, layouts, includes, and stylesheets in a way that can be overridden by your site’s content.

I personally use jekyll-theme-chripy in my website. So i am going use this theme as an example in this tutorial.you can choose whatever theme you like.

Pick up a theme

Optional: forking theme

I recommend you to fork your favourite theme. how to fork github repo

So you can host your jekyll website for free in Github-Pages, Netlify

1
2
3
git clone https://github.com/cotes2020/jekyll-theme-chripy

cd  jekyll-theme-chripy #Enter in to the folder

This command will clone the repo locally.

Deploying jekyll in docker

Create docker-compose file

1
nano docker-compose.yaml

this will open a CLI based text editor. add this file

1
2
3
4
5
6
7
8
9
10
11
version: '3'
services:
  jekyll-serve:
    container_name: jekyll
    image: jekyll/jekyll:latest
    volumes:
      - "$(PWD):/srv/jekyll"
    ports:
      - 80:4000
    command: 'jekyll serve'
    restart: unless-stopped

running docker-compose

1
docker-compose up .

If you use custom name for docker-compose file specify that also.

1
docker-compose -f custom-docker-file-name.yaml up 

this will bring up the container in port 80. open the http://localhost

SUCCESS!!

This post is licensed under CC BY 4.0 by the author.