I think the best option for a blog is a static website. I love blogging using Jekyll for that reason. Just write your posts in markdown and create a static website out of it so you can host everywhere for free or at a very affordable price.

Jekyll logo

So far, my local development environment for my blog was a MacBook Pro, and everything was installed on bare metal. By everything, I mean Jekyll and all its dependencies, such as Ruby. Unfortunately, I’m not a Ruby developer, and when something breaks, it’s hard to figure out how to fix it.

You might think once you set it up, you don’t need to change much. It’s true in general, except for macOS updates. However, after almost every major OS upgrade in recent years, I found out my blogging environment was broken. To mitigate this, I decided to use Docker.

Docker logo

Create your blog

I assume you don’t already have a Jekyll blog in this post. Creating a new one is very easy, as shown on the official Jekyll website:

gem install bundler jekyll
jekyll new my-awesome-site
cd my-awesome-site

Since we don’t want to install anything on our system, we are not going to use the first command and go straight to creating the site from within a Docker container like this:

docker run --rm -v "${PWD}:/srv/jekyll" jekyll/jekyll /bin/bash -c "jekyll new my-awesome-site"
cd my-awesome-site

We only have to do this once to initialize our blog. After that, each time we want to run it locally for testing purposes, we can run this:

docker run --rm -v "${PWD}:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll /bin/bash -c "jekyll serve --drafts --trace"

Notice the current directory is mounted, so make sure you are in the correct directory (which is the root of your blog) before running this command.

And that’s all there is to it!. Just navigate to 127.0.0.1:4000 on your machine to confirm it’s working and get cranking.

Happy blogging!

Conclusion

The moral of the story is: My biggest takeaway from all the containerized application movement is Never install anything on bare metal! Ever again! Whenever my development environment broke because of an unrelated change in the OS, I regretted not doing this earlier. No more!

Even though this blog itself is currently on WordPress, it’s not hard to migrate to Jekyll. I’ll get it up and running in minutes using the Docker images if that happens.

Resources

Categories: docker

Volkan Paksoy

Volkan Paksoy is a software developer with more than 15 years of experience, focusing mostly on C# and AWS. He’s a home lab and self-hosting fan who loves to spend his personal time developing hobby projects with Raspberry Pi, Arduino, LEGO and everything in-between.