fix(docker): use machinectl shell for rootless setup, not sudo -u - #92
Merged
Conversation
Production run hit: "Failed to enable unit: Unit docker.service does not exist". sudo -u user doesn't create a real login session, so dockerd-rootless-setuptool.sh and systemctl --user can't reach the persistent systemd --user instance loginctl enable-linger keeps running — the setuptool silently falls back to a non-systemd path instead of erroring. machinectl shell <user>@ attaches to the real session; XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS must be set inside it explicitly. Needs systemd-container for machinectl itself. Also stop hardcoding 'adam' as the rootless target: add --docker-user (defaults to adam), and offer to create it if missing instead of silently skipping — mirrors the confirm-before-create pattern already used for --root-ssh-keys/--pseudohome. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019nR4GeGS2EDhLypRNm1JhW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Failed to enable unit: Unit docker.service does not exist.sudo -u userdoesn't create a real login session, sodockerd-rootless-setuptool.sh/systemctl --usercan't reach the persistent systemd--userinstanceloginctl enable-lingerkeeps running, and the setuptool silently falls back to a non-systemd path instead of erroring._machinectl_shell(): runs the setuptool andsystemctl --user enable --nowviamachinectl shell <user>@withXDG_RUNTIME_DIR/DBUS_SESSION_BUS_ADDRESSset explicitly. Addssystemd-container(providesmachinectl) to rootless deps.--docker-user(defaultadam) so the rootless target isn't hardcoded; offers to create the user if missing instead of silently skipping.Test plan
ruff check/mypycleanmachinectl shellcommand string is well-formedhttps://claude.ai/code/session_019nR4GeGS2EDhLypRNm1JhW