I started using Docker for local development back in 2014. At the time, it was fairly rough around the edges, however the potential was clear!

Docker makes it possible to quickly and easily setup a consistent and portable development environment, putting the emphasis on writing code. It also helps facilitate a key aspect of the Twelve-Factory App methodology, specifically DEV / PRD parity.

As an example of my day-to-day usage, this blog is built using a static site generator, which historically required me to maintain a local installation of Jekyll, Ruby and RubyGems.

Anyone that has maintained a local development environment will know that they can be prone to issue, especially if you use the machine for other workloads.

With Docker Community Edition installed, you can create an isolated development environment, without having to install and maintain any dependencies on your Mac. Not only does this dramatically simply the setup process, but it also helps guarantee the ongoing integrity of your development environment.

To get started with Jekyll, it is as simple as using the Official Jekyll Docker Image. You can obviously interact with the image by passing the required options every time you create a container, or alternatively you can use Docker Compose.

Simply create a file in the root of your Jekyll site called “docker-compose.yml” and include the following configuration:

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


A description of the configuration can be found below:

Image: jekyll/jekyll:latest states that you want to leverage the Jekyll image with the latest tag.

Command: specifies the command(s) to execute in the container. For example, the jekyll serve command starts Jekyll’s development server. The options --watch and --incremental inform Jekyll to automatically regenerate the site when a file is changed.

Ports: forwards port 4000 of the container to your local port 4000.

Volumes: maps the current directory ~/jekyll-site/ to /srv/jekyll/, which is where the image is configured to look for your Jekyll site.

Once you have created the file, it is as simple as running the following Terminal command from the root of your Jekyll site:

docker-compose up


The container will now run, with your specified configuration, resulting in a Jekyll server being created and available via “http://0.0.0.0:4000”.