Dockerized Hugo CLI.

Docker Build Status

docker-hugo is a Dockerized Hugo CLI.

latest, 0.76.5Dockerfile
extended, 0.76.5-extendedDockerfile
docs, 0.76.5-docsDockerfile

Every image has the extended and docs variations. The first one contains the Hugo extended version binary, and the second one is the Hugo website.


$ docker run --rm -v /path/to/my/site/:/site/ \
    ntrrg/hugo [OPTIONS] [COMMAND]

Any command from the Hugo CLI might be used, for extra information use docker run --rm ntrrg/hugo help or see the official documentation.


Since the Hugo binary from the container is called by root, it is recommendable to add the -u Docker flag.

$ docker run --rm -v /path/to/my/site/:/site/ \
    -u $(id -u $USER) \
    -v ${TMPDIR:-/tmp/}:/tmp/ \
    ntrrg/hugo [OPTIONS] [COMMAND]


  • Create a new Hugo skeleton
$ docker run --rm -v /path/to/my/site/:/site/ \
    ntrrg/hugo new site .
  • Build a Hugo project
$ docker run --rm -v /path/to/my/site/:/site/ ntrrg/hugo
  • Run the Hugo server
$ docker run --rm -i -t -p 1313:1313 \
    -v /path/to/my/site/:/site/ \
    ntrrg/hugo server -DEF --baseUrl=/ \
        --bind= --appendPort=false
  • Run the Hugo server with a custom port
$ export PORT=8080
$ docker run --rm -i -t -p $PORT:$PORT \
    -v /path/to/my/site/:/site/ \
    ntrrg/hugo server -DEF --bind= --port=$PORT \
        --baseUrl=/ --appendPort=false


Working on this project I use/used:

Websocket for LiveReload using wrong port if Hugo binds to port 80.