DOCKER - 5 7 Solution Exercice Bind Mounts

This video is a live walkthrough of the bind-mounts exercise. The course repo's bind-mount sample directory contains Markdown files and a few other files — the standard template for a Jekyll site. Normally, running Jekyll natively would mean installing a specific Ruby version plus several gems on your machine. With Docker we skip all of that. We bind-mount the project directory into a Jekyll container and let it serve the site for us.

Edit on the host, see it live in the container

From the sample directory, start the container with a single command:

docker container run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve

The logs show Jekyll building the site from the source files, finishing with "server running". Open localhost in a browser and you'll see the default Jekyll site with one published post. The exercise is to edit that post and watch the change propagate.

  • Open the project in VS Code (or any editor)
  • Navigate to _posts/ and open the sample post file
  • Change the title: in the front matter and save
  • Switch back to the terminal — Jekyll logs announce the change was detected and the site rebuilt
  • Refresh localhost — the new title is live

This proves the loop: files on the host are mapped into the container, the container's watcher reacts to the host's filesystem events, and Jekyll regenerates its output without any restart. If you'd like to dig deeper into Jekyll, it's a static site generator widely used for personal blogs and free GitHub Pages sites — head to jekyllrb.com for the full documentation.

Summary

This lesson demonstrates the solution to a Docker bind mounts exercise using Jekyll, a static site generator. Rather than installing Jekyll locally with its specific Ruby dependencies, the instructor shows how Docker allows running Jekyll in a container while mounting local files from the host. The key benefit is that changes made to files on the host machine are immediately reflected in the running container, enabling live development without needing to install dependencies locally. Jekyll's built-in file detection automatically processes updates, making this workflow efficient for static site development.

Key points

  • Bind mounts enable mapping host directory files directly into a Docker container, eliminating the need to install tools locally
  • Using Docker with Jekyll avoids installing Ruby and specific dependencies on the host machine
  • Container automatically detects file changes from the host through bind mounts and updates the generated site accordingly
  • The Jekyll server runs inside the container and serves the generated website at localhost without host-side setup
  • Bind mounts demonstrate the practical advantage of containerization: develop with host tools while keeping system clean
  • Jekyll is a static site generator useful for creating free websites on GitHub with automatic file-to-site generation

FAQ

Why use Docker with Jekyll instead of installing it locally?

Docker eliminates the need to install Jekyll and its specific Ruby dependencies on your host machine. You can run Jekyll in a container while mounting your source files, avoiding local setup complexity and version conflicts.

How do file changes on the host automatically reflect in the running container?

Bind mounts create a direct mapping between the host directory and the container volume. When you modify files on the host, the container sees those changes immediately, and Jekyll's file detection system automatically regenerates the site.

What is Jekyll and what is it used for?

Jekyll is a static site generator that converts markdown and template files into a complete static website. It is particularly useful for creating free hosting options on GitHub and requires Ruby with specific dependencies to run.