Dockerize your own blog using jekyll

1 minute read

  • Bootstrap your own jekyll blog with docker-compose

Source Code


  • docker
  • docker-compose
  • Mac (kidding.. tested on a mac, let me know if it doesnt work for you)

Clone repo and run using command:

wget -O /tmp/z.$$ && 
   unzip -d . /tmp/z.$$ &&
   rm /tmp/z.$$
cd docker-bootstrap-jekyll-master

Goto http://localhost:4000

File Description
docker-compose.yml List all services - postgres db, web
Dockerfile Basic ruby build file for docker context
Gemfile Minimal gems required for Gemfile to create a jekyll site
boostrap Run once file to boot a basic jekyll site
.dockerignore Ignore tmp

File: docker-compose.yml

version: "3.9"
    build: .
      - .:/app
      - ./tmp/bundle:/bundle
    command: bash -c "bundle exec jekyll serve -b ''"
      - "3000:3000"
      BUNDLE_PATH:  /bundle

File: Dockerfile

FROM ruby:3.1.1

RUN apt-get update -qq
COPY . .

RUN gem install bundler 
RUN bundle install

CMD ["bundle", "exec, "jekyll" serve", "--host", ""]

File: Gemfile

source ""

ruby "3.1.1"

gem "jekyll"

# The theme of current site, locked to a certain version.
gem "minima"

# Plugins of this site loaded during a build with proper
# site configuration.
gem "jekyll-gist"
gem "jekyll-coffeescript"
gem "jekyll-seo-tag"

# A dependency of a custom-plugin inside `_plugins` directory.
gem "nokogiri"

File: bootstrap


# clone the repo and run:
# ./boostrap
# This is a one time only run file

# Force a build
touch Gemfile.lock && docker-compose build

# Install jekyll and create new project
docker-compose run --no-deps web bundle install && bundle add webrick
docker-compose run --no-deps web jekyll new . --force
docker-compose run --no-deps web bundle add webrick

# Exclude tmp files
echo "exclude: [tmp]" >> _config.yml
# Remove this file
rm bootstrap

# Start the application
docker-compose up

File: .dockerignore

# Ignore tmp