ERROR Failed to read Git log: fatal: detected dubious ownership in repository
6 months ago, I reported an issue: https://github.com/floryn90/docker-hugo/issues/171. And we thought it was resolved:
Should be solved with #172 If the issue persists, please raise another issue and I’ll take a look into details
Sorry it took so long to get back to you, but it looks like we're still having the problem. From https://gitlab.com/graphviz/graphviz.gitlab.io/-/jobs/10174457495:
Using docker image sha256:89f08fa59f89695c1f5ad4b490fadd3a7147aad9b2a3f228efd2169ddd81a230 for floryn90/hugo:0.147.6-ext-alpine-ci@sha256:f149d8421bf01ba903d0732bd21a6c2217dde24d3c45d420cf04b8963f095fbd with digest floryn90/hugo@sha256:f149d8421bf01ba903d0732bd21a6c2217dde24d3c45d420cf04b8963f095fbd ...
...
$ hugo
hugo: downloading modules …
hugo: collected modules in 14258 msStart building sites …
hugo v0.147.6-0a5fd8ebb8e2ca798515e8c564c14e32db3b4127+extended linux/amd64 BuildDate=2025-05-27T11:17:16Z VendorInfo=gohugoio
ERROR Failed to read Git log: fatal: detected dubious ownership in repository at '/builds/graphviz/graphviz.gitlab.io'
To add an exception for this directory, call:
git config --global --add safe.directory /builds/graphviz/graphviz.gitlab.io
Total in 20985 ms
Error: error building site: logged 1 error(s)
I see we already have some configuration of safe.directory here: https://github.com/floryn90/docker-hugo/blame/master/src/docker/alpine-ext/ext-alpine.df#L53
Given that /src is allowlisted, I tried https://gitlab.com/markhnsn/graphviz.gitlab.io/-/commit/d3143085ba82a9cc6afda743ad2c7aeb2a857b4c setting GIT_CLONE_PATH: /src to get the docker bind-mount for the git source to live in /src.
But this didn't work: the pipeline failed: https://gitlab.com/markhnsn/graphviz.gitlab.io/-/jobs/10176243224
Running with gitlab-runner 18.1.0~pre.317.g2147fb44 (2147fb44)
on green-3.saas-linux-small-amd64.runners-manager.gitlab.com/default Jhc_Jxvh, system ID: s_0e6850b[2](https://gitlab.com/markhnsn/graphviz.gitlab.io/-/jobs/10176243224#L2)bce1
Preparing the "docker+machine" executor
00:00
ERROR: Failed to remove network for build
ERROR: Job failed: the GIT_CLONE_PATH="/src" has to be within "/builds"
OK, GitLab has an (arbitrary?) requirement there.
i suppressed the warning in https://gitlab.com/graphviz/graphviz.gitlab.io/-/merge_requests/736
Thanks. I'm not sure if this will work yet; I think you're setting root's git config, I'm not sure if the hugo user's git will read from root's gitconfig. Will root and hugo have different home directories? with different .git directories? Not sure.
FYI, I just saw that upstream hugo is now also supplying docker images, but without many bells & whistles: https://github.com/gohugoio/hugo/pkgs/container/hugo.
Now the safe directory config should be present into root but also into hugo users. Give a try within your setup and let me know if the issue persists or not!