[SOLVED] Lastmod vs Docker Container



I’m trying to run Hugo from a container. I mount my local file system into the container and everything builds correctly. Doing a diff of my original generated site and the one produced via the containerized Hugo, I see that all uses of Page.Lastmod return a zero date. I’m trying to figure out how to fix this.

The container includes Hugo and git. Issuing a “git status” from within the container runs correctly and gives me valid info. Hugo runs and otherwise works perfectly, so all my options in config.toml are being respected. I’m using Hugo 0.42.1. My Dockerfile is pasted below for reference.

Anybody got ideas on this?


------ Dockerfile

FROM ruby:2.4-alpine

RUN echo 'gem: --no-document' >> /etc/gemrc

RUN apk add --no-cache \
    nodejs \
    ruby \
    ruby-dev \
    build-base \
    gcc \
    libc-dev \
    zlib-dev \
    libxslt-dev \
    libxml2-dev \
    libcurl \
    git \
    && apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted gnu-libiconv

ADD https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz /tmp
RUN tar -xf /tmp/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz -C /tmp \
    && mkdir -p /usr/local/sbin \
    && mv /tmp/hugo /usr/local/sbin/hugo \
    && rm -rf /tmp/hugo_${HUGO_VERSION}_linux_amd64 \
    && rm -rf /tmp/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz \
    && rm -rf /tmp/LICENSE.md \
    && rm -rf /tmp/README.md

RUN npm install -g \
    html-minifier \
    sass \
    uglify-js \

RUN gem install \
    mdl \

ENV PATH /usr/bin:$PATH

# TODO: replace with your ENTRYPOINT or CMD.
CMD [ "/usr/bin/ruby", "-v"]

Sorry, no idea. But I did want to encourage you to search Docker-specific help sites. It isn’t a Hugo issue, per se. Good luck! :slight_smile:


Well, it’s at the boundary of Hugo/Docker/Git. Hugo generally works from the container, Git works from the container, and the git command is in the path. I browsed the Hugo sources and found it’s just calling out to the git command to do its bidding. I’m not seeing any log messages claiming that the git command was not found by Hugo, and there are no error messages at all. Just 0 values being returned.

The only thing I can think of is that Hugo is somehow not able to get the output from the git command it launched. So it ran the command with no error, read no output, and then just returned 0 upstream.


If you want more help from these forums, please see Requesting Help and share your code repo. We can’t reproduce your issue without the Hugo project.

Even then, it will require someone using Docker in this way, or having easy access to a Docker system to reproduce. I hope you get the help you are looking for.


Aha, I found the issue. It was indeed about stdio.

When running the container with ‘docker run’ I added the -i and -t arguments that related to docker’s behavior around stdio. This solved the problem, and Hugo correctly acquire GitHub’s last modification time.