DOCKER - 5 6 Exercice Bind Mounts
Bind mounts shine for local development and testing. Because they map a host directory straight into the container, you can edit files in your favourite editor and the running process inside the container picks up the changes immediately. In this exercise we'll use a static site generator called Jekyll. Don't worry — this is not a web-dev tutorial, we'll only edit one line of Markdown. The goal is to internalise the idea of host files mounted inside a container, modified on the host, instantly visible inside.
A live Jekyll preview backed by a bind mount
Jekyll takes Markdown files (essentially plain text) and renders them into a static HTML website. It's what GitHub Pages uses under the hood. Normally you'd have to install Ruby, Bundler, a watcher and a tiny web server on your machine. With Docker, someone packaged the whole stack in a single image — you don't install any of it on the host.
Open the sample bind-mount directory in the course repo and run:
docker container run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve
This publishes container port 4000 on host port 80 and bind-mounts the current directory into /site inside the container. Open localhost in a browser — you'll see the default site generated by Jekyll.
- Edit any post under the
_posts/directory in your editor of choice (VS Code, Vim, anything) - Save — Jekyll's watcher detects the change and rebuilds the site automatically
- Refresh your browser to see the new content
- Run
docker container logs <id>in another tab to see Jekyll announce each file change and rebuild
That's the full bind-mount story: source code lives on the host, the tooling lives in the container, and the loop between edit and preview is as fast as a normal local dev setup — without polluting your machine. If you're stuck, the next lesson walks through this exercise live.