3

用 Docker 运行 Jekyll

 2 years ago
source link: https://livid.v2ex.com/essays/2018/12/31/jekyll-docker.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

用 Docker 运行 Jekyll

Dec 31, 2018

很喜欢 Jekyll 这个静态网站生成框架,这个站就是用 Jekyll 做的。但是总感觉 Jekyll 的安装是一件很麻烦的事情。直接安装到 Host OS 上是一种污染环境的方法,而我又不想去花时间研究到底怎样才是管理 Ruby 依赖包的最科学的方式。所以用 Docker 来让这个网站可以在本地跑起来,是最好的方式了。而且 Docker 这样的方式也通吃 macOS 和 Windows。

首先是获取 Jekyll 的最新 Docker 镜像:

docker pull jekyll/jekyll

然后切换到你的 Jekyll 网站所在目录,执行这条命令启动 Jekyll:

docker run --mount type=bind,source=$(pwd),target=/srv/jekyll \
-p 4000:4000 --name blog -it jekyll/jekyll \
jekyll serve

然后就可以通过 localhost:4000 访问到这个 Jekyll 的动态生成结果了。

因为我们给这个 Container 赋予了名字 blog,所以之后如果再次需要这个 Container 的话,只需要这样就可以启动:

docker start -i blog

参考文档 https://github.com/envygeeks/jekyll-docker/blob/master/README.md


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK