Newbie: Running hugo in a container on ubuntu

I toyed with Hugo (with docsy) about a year ago and have come back to look at it. docsy has moved on to a later version as has Hugo.

Previously I used klakegg/hugo but this is now too old for the docsy and Hugo versions I need… so I have moved to… hugomods/hugo

My site has been git inited and all the files are owned by me (a non-root user) on Ubuntu

When I run the container I get…

ERROR Failed to read Git log: fatal: detected dubious ownership in repository at ‘/src’
To add an exception for this directory, call:

    git config --global --add safe.directory /src

Now I presume this is because the uid of the container is not me so when the container tries to do git commands it finds a mismatch in ownership. Is there a way around that?

I liked this way of working… my directory was SAMBA shared so I could edit the underlying files on windows.

I suggest you take this up with dockerfile owner.

I always include this in the dockerfile:

# Configure Git
RUN git config --system --add safe.directory /WHATEVER && \
    git config --system --add core.quotepath false
1 Like

So that would be the author at hugomods/hugo?

Is there a way for me to mixin the extra commands?

(Not a docker expert)

Yes.

Roll your own dockerfile.

I think this brings us back to…

I created a

Dockerfile

FROM hugomods/hugo

# Configure Git
RUN git config --system --add safe.directory /src && \
    git config --system --add core.quotepath false

CMD hugo server -D --baseURL "http://babel.mydomain.com" --bind 0.0.0.0

and did a

docker build -t hugo-app .

and created a

docker-compose.yaml

version: "3.3"

services:

  site:
    image: hugo-app
    build:
      context: .
    ports:
      - "1313:1313"
    volumes:
      - .:/src

and then did a

docker compose -d up

And now I seem to have a served site. Hopefully this information will prove useful to someone asking the question in future.

1 Like

cc @razon

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.