To get started let’s abstract our Jekyll build into a Dockerfile, it is a bit more work in the beginning but once we are done our Dockerfile should be re-usable for the rest of our Jekyll projects.


FROM ruby

WORKDIR /usr/src/app

COPY . /usr/src/app

apt-get update && \
apt-get install -y build-essential && \
rm -rf /var/lib/apt/lists/* && \
bundle install && \
jekyll clean && \
jekyll build

EXPOSE  4000

CMD ["jekyll" "--help"]

To build the Docker image the command is quite simple:

docker build -t .

This will build a Docker image tagged as

To run that image and tell it to run jekyll serve the command looks like this, it is quite long so put it in a bash script:

docker run -it --rm -v $(pwd):/usr/src/app -p 4000:4000 ruby -S jekyll serve --host= --watch --force_polling

You can run any Jekyll command within the image like this:

Let’s run a normal Jekyll build:

docker run -it --rm -v $(pwd):/usr/src/app -p 4000:4000 ruby -S jekyll build

Now a clean:

docker run -it --rm -v $(pwd):/usr/src/app -p 4000:4000 ruby -S jekyll clean


Ryan is a hacker dad living in Cape Town, South Africa who likes Skate Boarding JavaScript and Functional Programming.

ryanwild @javascript_fn