This blog is hosted on GitHub pages and his generated by Jekyll. Hosting a personal blog on GitHub is cool because it’s totally free and it is also very fast due to the fact that the pages are static.

The only drawback for a Microsoft guy like me, it’s that I need to install Ruby on my machine to be able to test my website. It’s relativly easy to install Ruby and Jekyll on Windows even if it is not officialy supported. But every time I try to install Ruby on my machine, I have nasty issues with HTTPS when trying to install gems.

Last week, my machine crashed and I had to rebase it. But this time I have taken another way to have Jekyll up & running on my machine. I use Docker!

The folks of Jekyll have made Docker image available on Docker Hub and the documentation can be found on GitHub. I will show you how to get it running on your Windows machine.

First, we will pull the image on our Docker images.

docker pull jekyll/jekyll:pages

Note that we add the pages tag because we are targeting GitHub Pages. This image contains the same gems that are available on GitHub Pages.

Now, we need to run Jekyll from the Docker Image:

docker run --rm --volume=$(pwd):/srv/jekyll -p 4000:4000  jekyll/jekyll:pages jekyll serve --watch --incremental --force_polling

You will see something like this:

Configuration file: /srv/jekyll/_config.yaml
Configuration file: /srv/jekyll/_config.yaml
            Source: /srv/jekyll
       Destination: /srv/jekyll/_site
 Incremental build: enabled
      Generating...
                    done in 2.02 seconds.
 Auto-regeneration: enabled for '/srv/jekyll'
Configuration file: /srv/jekyll/_config.yaml
    Server address: http://0.0.0.0:4000/
  Server running... press ctrl-c to stop.

That’s all! Now, browse to http://localhost:4000 and your site is running. So far, so cool. But it is a bit cumbersome to enter all the command arguements every time you want to build your site. Let’s welcome Docker Compose. Just create a file called docker-compose.yml in your website folder with these contents:

jekyll:
    image: jekyll/jekyll:pages
    command: jekyll serve --watch --incremental --force_polling
    ports:
        - 4000:4000
    volumes:
        - .:/srv/jekyll

Here you can define the volume as a relative path. This file will also take care of pulling down the image from the internet if it is not present on your machine. Now run docker-compose up when you want to build your website.