Skip to content

fix(docker): use machinectl shell for rootless setup, not sudo -u - #92

Merged
adamamyl merged 1 commit into
mainfrom
fix/docker-rootless-machinectl
Jul 11, 2026
Merged

fix(docker): use machinectl shell for rootless setup, not sudo -u#92
adamamyl merged 1 commit into
mainfrom
fix/docker-rootless-machinectl

Conversation

@adamamyl

@adamamyl adamamyl commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes production failure: 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/systemctl --user can't reach the persistent systemd --user instance loginctl enable-linger keeps running, and the setuptool silently falls back to a non-systemd path instead of erroring.
  • Adds _machinectl_shell(): runs the setuptool and systemctl --user enable --now via machinectl shell <user>@ with XDG_RUNTIME_DIR/DBUS_SESSION_BUS_ADDRESS set explicitly. Adds systemd-container (provides machinectl) to rootless deps.
  • Adds --docker-user (default adam) so the rootless target isn't hardcoded; offers to create the user if missing instead of silently skipping.

Test plan

  • ruff check / mypy clean
  • Dry-run verified the exact machinectl shell command string is well-formed

https://claude.ai/code/session_019nR4GeGS2EDhLypRNm1JhW

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
@adamamyl
adamamyl merged commit f8f91b9 into main Jul 11, 2026
1 of 3 checks passed
@adamamyl
adamamyl deleted the fix/docker-rootless-machinectl branch July 11, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant