[PR #68] [MERGED] feat(containers): bind /etc/hostname from a container-id path so apps can self-identify #69

Closed
opened 2026-10-15 12:51:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/68
Author: @JBailes
Created: 6/7/2026
Status: ✅ Merged
Merged: 6/7/2026
Merged by: @JBailes

Base: main ← Head: fix/container-id-hostname-bind


📝 Commits (1)

  • f726940 feat(containers): bind /etc/hostname from a container-id path so apps can self-identify

📊 Changes

3 files changed (+78 additions, -0 deletions)

View changed files

📝 internal/lxc/config.go (+27 -0)
📝 internal/lxc/config_test.go (+24 -0)
📝 internal/lxc/manager.go (+27 -0)

📄 Description

Problem

Apps that identify their own container by scanning /proc/self/mountinfo for the 64-hex container ID — e.g. Wolf (get_current_container) — can't on the LXC/PVE path. Docker bind-mounts /etc/hostname from /var/lib/docker/containers/<id>/hostname, so the ID is in mountinfo; the daemon never did this, so the ID is absent. Wolf then logs "No valid container ID found in mountinfo / automatic mounts matching is disabled" and can't translate host↔container paths, which breaks the udev records / device mapping it pushes into sibling session containers (e.g. virtual controllers get no working input).

Fix

Write the hostname to <statepath>/containers/<id>/hostname and bind-mount it at /etc/hostname (both the PVE-CT and docker build paths), matching Docker's …/containers/<id>/hostname bind. Removed with the container.

Verification

  • go test ./internal/lxc/ passes; new TestContainerIDHostnameBind covers both build paths.
  • On a PVE host, manually adding this exact bind to the Wolf CT made Wolf self-identify — the warnings cleared and it logged Detected mounted /etc/wolf in the host as /etc/wolf / /run/user/wolf … (automatic mounts matching enabled).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/68 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 6/7/2026 **Status:** ✅ Merged **Merged:** 6/7/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/container-id-hostname-bind` --- ### 📝 Commits (1) - [`f726940`](https://github.com/games-on-whales/LXC2Docker/commit/f726940782e34cb685c4fd5d4f9889a6e4d19f53) feat(containers): bind /etc/hostname from a container-id path so apps can self-identify ### 📊 Changes **3 files changed** (+78 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/lxc/config.go` (+27 -0) 📝 `internal/lxc/config_test.go` (+24 -0) 📝 `internal/lxc/manager.go` (+27 -0) </details> ### 📄 Description ## Problem Apps that identify their own container by scanning `/proc/self/mountinfo` for the 64-hex container ID — e.g. Wolf (`get_current_container`) — can't on the LXC/PVE path. Docker bind-mounts `/etc/hostname` from `/var/lib/docker/containers/<id>/hostname`, so the ID is in mountinfo; the daemon never did this, so the ID is absent. Wolf then logs *"No valid container ID found in mountinfo / automatic mounts matching is disabled"* and can't translate host↔container paths, which breaks the udev records / device mapping it pushes into sibling session containers (e.g. virtual controllers get no working input). ## Fix Write the hostname to `<statepath>/containers/<id>/hostname` and bind-mount it at `/etc/hostname` (both the PVE-CT and docker build paths), matching Docker's `…/containers/<id>/hostname` bind. Removed with the container. ## Verification - `go test ./internal/lxc/` passes; new `TestContainerIDHostnameBind` covers both build paths. - On a PVE host, manually adding this exact bind to the Wolf CT made Wolf self-identify — the warnings cleared and it logged `Detected mounted /etc/wolf in the host as /etc/wolf` / `/run/user/wolf …` (automatic mounts matching enabled). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:46 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#69
No description provided.