Hugo Docker Image
Hugo is a fast and flexible static site generator, written in Go.
Hugo flexibly works with many formats and is ideal for blogs, docs, portfolios and much more.
Hugo’s speed fosters creativity and makes building a website fun again.
This Lightweight Docker Image is based on Alpine, and comes with rsync for Continuous Deployment.
To print Hugo Help:
docker run --rm -it jguyomard/hugo-builder hugo help
To create a new Hugo managed website:
docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo new site mysite cd mysite
To build your site:
docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo
To serve your site locally:
docker run --rm -it -v $PWD:/src -p 1313:1313 -u hugo jguyomard/hugo-builder hugo server -w --bind=0.0.0.0
http://localhost:1313/ in your browser.
For ease of use, you can create a bash alias:
alias hugo='docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder hugo' alias hugo-server='docker run --rm -it -v $PWD:/src -p 1313:1313 -u hugo jguyomard/hugo-builder hugo server --bind 0.0.0.0'
Now, you can use
hugo new foo/bar.md,
hugo-server -w, etc.
By default, this docker image run as the root user. This makes it easy to use as base image for other Dockerfiles (switching back and forth adds extra layers and is against the current best practices advised by Docker). Most (all official?) base images leave the default user as root.
However, this docker image also define a non-root user
hugo (UID 1000, GID 1000) which can be switched on at run time using the
--user flag to
docker run --rm -it -v $PWD:/src --user hugo jguyomard/hugo-builder hugo
You can also change this according your needs, by setting another UID/GID. For instance, to run hugo with user
www-data:www-data (UID 33, GID 33) :
docker run --rm -it -v $PWD:/src -u 33:33 jguyomard/hugo-builder hugo
extras tag add some others tools and packages:
To use this version:
docker run --rm -it -v $PWD:/src -u hugo jguyomard/hugo-builder:extras hugo
I use this Docker image for Continuous Deployment. You can find some CI config examples on
This Docker image also comes with:
If you have any problems with or questions about this docker image, please contact me through a GitHub issue.
If the issue is related to Hugo itself, please leave an issue on the Hugo official repository.
You are invited to contribute new features, fixes or updates to this container, through a Github Pull Request.