<commit_before>---
title: "Simple websites with Jekyll and Docker"
author: <NAME>
date: 2015-05-03T01:01:56-05:00
modified: 2016-04-18
excerpt: "Learn how to host your own simple websites with Jekyll and Docker."
permalink: /simple-websites-jekyll-docker/
tags: [blogging, devops, jekyll, docker, server, webmaster, vm, virtualization, hosting]
categories: [tutorials]
header:
  overlay_image: sailing-boat-679833_1280.jpg
  overlay_filter: 0.5
  caption: "Photo credit: [Counselling](http://pixabay.com/en/sailing-boat-sea-ocean-679833/)"
---
{% include toc %}

Looking to create a simple website but don’t want to pay through the nose for hosting? Get started for free with Jekyll and Docker.

> Learn how to create and host your own static website using Jekyll and Docker

<!--more-->

**Primary Objective:** Create and host simple websites with [Jekyll][2] and Docker using Mark Otto’s beautiful and minimalistic [Lanyon][1] theme.
{: .notice--success}

**Secondary Objective:** Earn some geek cred by learning how to use Jekyll, Docker and Passenger; and learning how to deploy your website from the command line.
{: .notice--success}

# Create Docker image

Alright, now onto the fun stuff! In this section we’re going to clone a seed for our Jekyll site and use it to create a Docker image we can run locally and on a server.

**Tip:** Never used Docker before? No worries! Just head over to the [Docker Jumpstart](http://odewahn.github.io/docker-jumpstart/) by <NAME> to start learning.
{: .notice--info}

## Install Docker

Docker is designed to run on Linux. To use it on Windows you’ll need to run a virtual machine with Linux on it. To do so [download and install Virtual Box](https://www.virtualbox.org/) and [docker-machine](https://github.com/docker/machine), and follow the setup instructions for each. Mac OS X users can use [dlite](https://github.com/nlf/dlite) and skip using VirtualBox and `docker-machine` altogether.

If using `docker-machine`, **create a virtual machine** using the virtualbox driver and then **start the Docker daemon** on it, setting any environment variables suggested by `docker-machine` to enable proper connection from the host machine to the VM:

    docker-machine create -d virtualbox default
    docker-machine start default

Once Docker is installed, run it with:

    docker

You’ll see a command listing if everything worked. If not, ensure your Docker environment is configured correctly before proceeding.

## Clone Jekyll seed

In order to build a Docker image to run our Jekyll site we need an actual site to start with. Rather than creating one from scratch we’re going to use an open-source seed called [Lanyon][1] by <NAME>. Go ahead and **clone it now**:

    git clone https://github.com/poole/lanyon.git lanyon && cd $_

**Tip:** Looking for something more complex than Lanyon? Check out some [wonderful themes](https://mademistakes.com/work/jekyll-themes/) by <NAME>.
{: .notice--info}

## Configure Docker host container

Next we’ll configure a Docker container to host a Docker image we can use to run our site on DigitalOcean. Start by creating a `Dockerfile`, `Gemfile` and `nginx.conf` file in the root folder of the cloned Jekyll seed, modeling from the following:

{% gist jhabdas/e0d5e3bed0316f1a5783 %}

What this will do is build a container image based off a container called [passenger-docker](https://github.com/phusion/passenger-docker), exposes traffic on 80 for port-forwarding, copies the site into the container, builds the site using Jekyll, configures Nginx to use it and then serves the whole thing up using [Passenger](https://www.phusionpassenger.com).

## Install Ruby dependencies
<commit_msg>update docker installation instructions<commit_after>---
title: "Simple websites with Jekyll and Docker"
author: <NAME>
date: 2015-05-03T01:01:56-05:00
modified: 2017-05-16T11:48:00+08:00
excerpt: "Learn how to host your own simple websites with Jekyll and Docker."
permalink: /simple-websites-jekyll-docker/
tags: [blogging, devops, jekyll, docker, server, webmaster, vm, virtualization, hosting]
categories: [tutorials]
header:
  overlay_image: sailing-boat-679833_1280.jpg
  overlay_filter: 0.5
  caption: "Photo credit: [Counselling](http://pixabay.com/en/sailing-boat-sea-ocean-679833/)"
---
{% include toc %}

Looking to create a simple website but don’t want to pay through the nose for hosting? Get started for free with Jekyll and Docker.

> Learn how to create and host your own static website using Jekyll and Docker

<!--more-->

**Primary Objective:** Create and host simple websites with [Jekyll][2] and Docker using Mark Otto’s beautiful and minimalistic [Lanyon][1] theme.
{: .notice--success}

**Secondary Objective:** Earn some geek cred by learning how to use Jekyll, Docker and Passenger; and learning how to deploy your website from the command line.
{: .notice--success}

# Create Docker image

Alright, now onto the fun stuff! In this section we’re going to clone a seed for our Jekyll site and use it to create a Docker image we can run the same site both locally and on a server.

**Tip:** Never used Docker before? No worries! Just head over to the [Docker Jumpstart](http://odewahn.github.io/docker-jumpstart/) by <NAME> to start learning.
{: .notice--info}

## Install Docker

Docker is designed to run on a variety of platforms including macOS, Windows and several varieties of Linux. To get Docker head to [Install Docker](https://docs.docker.com/engine/installation/) on the docker docs website. Please install Docker before proceeding.

## Clone Jekyll seed

In order to build a Docker image to run our Jekyll site we need an actual site to start with. Rather than creating one from scratch we’re going to use an open-source seed called [Lanyon][1] by <NAME>. Go ahead and **clone it now**:

    git clone https://github.com/poole/lanyon.git lanyon && cd $_

**Tip:** Looking for something more complex than Lanyon? Check out some [wonderful themes](https://mademistakes.com/work/jekyll-themes/) by <NAME>.
{: .notice--info}

## Configure Docker host container

Next we’ll configure a Docker container to host a Docker image we can use to run our site on DigitalOcean. Start by creating a `Dockerfile`, `Gemfile` and `nginx.conf` file in the root folder of the cloned Jekyll seed, modeling from the following:

{% gist jhabdas/e0d5e3bed0316f1a5783 %}

What this will do is build a container image based off a container called [passenger-docker](https://github.com/phusion/passenger-docker), exposes traffic on 80 for port-forwarding, copies the site into the container, builds the site using Jekyll, configures Nginx to use it and then serves the whole thing up using [Passenger](https://www.phusionpassenger.com).

## Install Ruby dependencies

{'fraction_non_alphanumeric': 0.09025003698772008, 'fraction_numerical': 0.019529516200621395, 'mean_word_length': 4.522875816993464, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 12, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3832329', 'n_tokens_mistral': 2084, 'n_tokens_neox': 1892, 'n_words': 892}