Docker Development Environment Setup
This guide will help you set up a Docker-based development environment for the Kelomai blog using Docker Desktop.
Prerequisites
- Docker Desktop installed and running
- Visual Studio Code (optional, for dev container support)
- Dev Containers extension for VS Code (optional)
Quick Start
Option 1: Using Docker Compose (Recommended)
- Start the development server:
docker-compose up - Access your blog:
- Open your browser to http://localhost:4000
- The site will auto-reload when you make changes (LiveReload enabled)
- Stop the server:
- Press
Ctrl+Cin the terminal - Or run:
docker-compose down
- Press
Option 2: Using VS Code Dev Containers
- Open in VS Code:
- Open this folder in VS Code
- You should see a prompt: “Reopen in Container”
- Click “Reopen in Container” (or use Command Palette: “Dev Containers: Reopen in Container”)
- Wait for the container to build:
- First time will take a few minutes to build the image and install dependencies
- Subsequent opens will be much faster
- Start Jekyll:
- The dev container automatically runs
bundle install - Open a terminal in VS Code and run:
bundle exec jekyll serve --host 0.0.0.0 --livereload - Or simply run:
./build.sh
- The dev container automatically runs
- Access your blog:
- VS Code will automatically forward port 4000
- Click the notification or go to http://localhost:4000
Common Commands
Rebuild the Docker image:
docker-compose build --no-cache
Run in detached mode (background):
docker-compose up -d
View logs:
docker-compose logs -f
Stop and remove containers:
docker-compose down
Execute commands in the running container:
docker-compose exec jekyll bash
Install new gems:
# If you add gems to Gemfile, rebuild:
docker-compose down
docker-compose build
docker-compose up
Working with Your Blog
Creating a new post:
- Create a new file in
_posts/directory with the format:YYYY-MM-DD-title.md - Add front matter and content
- Save the file
- Your browser will automatically refresh with the new post
Editing existing posts:
- Open any file in
_posts/ - Make your changes
- Save the file
- Changes will appear immediately in your browser
Troubleshooting
Port 4000 is already in use:
# Find and kill the process using port 4000
lsof -ti:4000 | xargs kill -9
# Or change the port in docker-compose.yml:
# ports:
# - "4001:4000"
Container won’t start:
# Clean everything and rebuild
docker-compose down -v
docker-compose build --no-cache
docker-compose up
Changes not appearing:
- Ensure the container is running:
docker-compose ps - Check the logs:
docker-compose logs -f - Try a hard refresh in your browser:
Cmd+Shift+R(Mac) orCtrl+Shift+R(Windows/Linux)
Permission issues:
# The container runs as root to avoid permission issues on macOS
# If you encounter issues, try:
docker-compose down
docker-compose up
What’s Included
- Ruby 3.2: Latest stable Ruby version
- Jekyll 4.4.1: Latest Jekyll with all your plugins
- Bundler 2.6.6: For dependency management
- LiveReload: Automatic browser refresh on file changes
- Volume caching: Faster gem installation with persistent bundle cache
Development Workflow
- Start Docker Desktop
- Run
docker-compose up - Edit your blog posts in
_posts/ - View changes instantly at http://localhost:4000
- When done, press
Ctrl+Cto stop
Benefits of This Setup
- No Ruby installation needed on your Mac
- Consistent environment across different machines
- Isolated dependencies won’t conflict with other projects
- Easy cleanup - just remove the containers
- Fast setup for new team members or machines
- Works on macOS, Windows, and Linux
Next Steps
- Check Jekyll documentation for more features
- Explore the
_config.ymlfor site configuration - Review existing posts in
_posts/for examples - Customize the theme in
css/and_includes/