hermes - ✅(Solved) Fix [Bug]: HERMES_UID & HERMES_GID are not used in Docker [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12696Fetched 2026-04-20 12:17:22
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×1referenced ×1renamed ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

PR fix notes

PR #12623: fix(docker): HERMES_UID and HERMES_GID usage in container + feature(docker): add new SYNC_CODE_DIR environment variable

Description (problem / solution / changelog)

What does this PR do?

The entrypoint contains runtime ownership/remap logic that only works correctly when the container starts as root. After the image build switched to running as hermes, that logic no longer had the privileges needed to honor HERMES_UID / HERMES_GID.

Separately, some downstream/containerized workflows need access to the exact Hermes source code shipped in the image so they can install it into their own virtualenv or consume files like requirements.txt from a mounted path.

This PR makes two Docker-focused changes:

  1. Restores the intended HERMES_UID / HERMES_GID behavior by switching the image back to root before the runtime entrypoint executes.
  2. Adds an optional SYNC_CODE_DIR environment variable that rsyncs the installed Hermes source tree to a writable external directory at container startup (to allow third party solutions to add hermes agent to their venv; example: Hermes WebUI)

Related Issue

I did not see an existing issue, and created one https://github.com/NousResearch/hermes-agent/issues/12696

I discovered the issue while trying to use HERMES_UID and HERMES_GID and found that they were not being respected (the intent was to provide an Unraid template for Hermes Agent, and the Hermes WebUI project; the second one would need the new feature to function)

The root cause is the USER hermes usage in the Dockerfile while the entrypoint.sh checks against id = 0 (ie the root user)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)

Changes Made

  • Dockerfile:

    • Installs rsync
    • Switches back to USER root after dependency installation so the entrypoint.sh can perform UID/GID and ownership setup correctly at runtime
  • docker/entrypoint.sh

    • Adds optional SYNC_CODE_DIR support. If SYNC_CODE_DIR points to an existing writable directory, the entrypoint copies /opt/hermes into it with rsync (excludes runtime/build noise such as .venv, .git, __pycache__, *.pyc, *.pyo, and .playwright + uses --delete so the synced directory stays aligned with the source tree across restarts). Fails open: if the sync target is missing or not writable, container startup continues normally

Behavior: Default behavior is unchanged when SYNC_CODE_DIR is unset. The sync is best-effort and does not block container startup. This is mainly useful for bind-mounted development workflows and derived images that want to install Hermes into a separate venv.

How to Test

<!-- Steps to verify this change works. For bugs: reproduction steps + proof that the fix works. -->
  1. docker build -f Dockerfile --tag ha:test .
  2. mkdir -p ../test/{data,src}
  3. docker run --rm -it -e HERMES_UID=$(id -u) -e HERMES_GID=$(id -g) -v $(pwd)/../test/data:/test/data -e HERMES_HOME=/test/data -v $(pwd)/../test/src:/test/src -e SYNC_CODE_DIR=/test/src ha:test

Result:

Changing hermes UID to 1000
Changing hermes GID to 1000
Dropping root privileges
Running as 1000:1000 (hermes:hermes)
SYNC_CODE_DIR is set to /test/src, copying code there
Code copied to SYNC_CODE_DIR successfully (...
Syncing bundled skills into ~/.hermes/skills/ ...
  + dogfood
[...]
Done: 77 new, 0 updated, 0 unchanged. 77 total bundled.
[... followed by Hermes TUI access]

Local folders:

  • ../test/data contains the hermes runtime (including config.yaml, ...) owned by user matching HERMES_UID and HERMES_GID
  • ../test/src contains the content of /opt/hermes (without the .venv and other dropped files/folders) to support usage with 3rd party extensions more easily

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
    • only fix container build and usage, no hermes behavior
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
    • described in how to test, this is not a recursion issue, same comment as above re no change to hermes behavior
  • I've tested on my platform: Ubuntu 24.04 w/ Docker

Documentation & Housekeeping

  • [N/A] I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • [N/A] I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • [N/A] I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • [N/A] I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • [N/A] I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Changed files

  • Dockerfile (modified, +4/-1)
  • docker/entrypoint.sh (modified, +21/-0)

PR #12733: fix(docker): run entrypoint as root so HERMES_UID/HERMES_GID remapping works

Description (problem / solution / changelog)

Fixes #12696

The Dockerfile's final USER hermes directive meant the container always started as UID 10000, so the entrypoint's existing UID/GID remapping code (which requires root for usermod/groupmod) was always skipped.

Fix: Add USER root before the runtime section so the entrypoint runs as root, performs the UID/GID remapping if HERMES_UID/HERMES_GID are set, then drops privileges via gosu hermes.

Changed files

  • Dockerfile (modified, +3/-0)

Code Example

N/A

---
RAW_BUFFERClick to expand / collapse

Bug Description

HERMES_UID and HERMES_GID are not used by Docker.

Steps to Reproduce

  1. docker run -e HERMES_UID=1000 nousresearch/hermes-agent

Expected Behavior

The hermes user would have changed to 1000

Actual Behavior

The hermes user is still 10000

Affected Component

Other

Messaging Platform (if gateway-related)

No response

Debug Report

N/A

Operating System

Ubuntu 24.04 w/ Docker

Python Version

No response

Hermes Version

Docker built from source

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

Apparently, this happened yesterday in https://github.com/NousResearch/hermes-agent/commit/a828daa7f8eb8f2969c2c46a7796845bab900d04 The original working solution was from https://github.com/NousResearch/hermes-agent/commit/fee0e0d35e093d2062c2deee3e321a9a44ebe017

Proposed Fix (optional)

Re-add USER root before start of entrypoint.sh

Already submitted a PR https://github.com/NousResearch/hermes-agent/pull/12623

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The issue can be fixed by re-adding USER root before the start of entrypoint.sh in the Docker configuration to properly utilize the HERMES_UID and HERMES_GID environment variables.

Guidance

  • Review the Dockerfile and ensure that USER root is included before running the entrypoint.sh to allow for user ID changes.
  • Verify that the HERMES_UID and HERMES_GID environment variables are being set correctly in the Docker run command.
  • Check the commit history to understand the changes made and how they affected the user ID setting, specifically the commits mentioned in the root cause analysis.
  • Test the fix by running the Docker container with the updated configuration and checking the user ID of the hermes user.

Example

No code snippet is provided as the fix involves modifying the Dockerfile, which is not shown in the issue.

Notes

The provided root cause analysis suggests that a recent commit introduced this issue, and a proposed fix has already been submitted as a PR. This guidance is based on the information provided in the issue and may not be applicable if the Dockerfile or other configurations have been modified.

Recommendation

Apply the workaround by re-adding USER root before the start of entrypoint.sh as this directly addresses the issue described and has been proposed as a fix in the submitted PR.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: HERMES_UID & HERMES_GID are not used in Docker [2 pull requests, 1 participants]