Skip to content

Allow DOCKER_HOST override in rootless Docker setup - #16

Merged
f3l1x merged 1 commit into
masterfrom
claude/docker-host-env-var-07o59y
Aug 10, 2026
Merged

Allow DOCKER_HOST override in rootless Docker setup#16
f3l1x merged 1 commit into
masterfrom
claude/docker-host-env-var-07o59y

Conversation

@f3l1x

@f3l1x f3l1x commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

This change makes the rootless Docker configuration respect an existing DOCKER_HOST environment variable, allowing users to override the default socket location or use alternative Docker daemons (mounted host sockets, remote daemons, etc.).

Key Changes

  • dockerd-rootless-start.sh:

    • Modified to respect pre-existing DOCKER_HOST environment variable instead of always overwriting it
    • Added early check to detect if a daemon is already reachable at the configured DOCKER_HOST
    • Added validation to ensure DOCKER_HOST points to a unix socket path ending in /docker.sock
    • Derives XDG_RUNTIME_DIR from the DOCKER_HOST path to keep the daemon and CLI in agreement
    • Provides helpful error messages when DOCKER_HOST is set to an unsupported value
  • Dockerfile:

    • Updated /etc/profile to use DOCKER_HOST="${DOCKER_HOST:-...}" pattern, making the default conditional
    • Added clarifying comments explaining that these are defaults that can be overridden
  • README.md:

    • Documented that both XDG_RUNTIME_DIR and DOCKER_HOST are defaults only
    • Explained that environment-provided values (from templates, docker run, mounted sockets, remote daemons) are respected
    • Clarified the behavior of dockerd-rootless-start when DOCKER_HOST is pre-configured

Implementation Details

The startup script now follows this logic:

  1. Use DOCKER_HOST from environment if set, otherwise default to the rootless socket path
  2. Check if a daemon is already reachable at that location
  3. If reachable, exit successfully without starting a new daemon
  4. If not reachable, validate that DOCKER_HOST is a unix socket path and derive XDG_RUNTIME_DIR from it
  5. Create the runtime directory if needed and start the rootless daemon

This enables flexible deployment scenarios while maintaining backward compatibility with existing setups.

https://claude.ai/code/session_017jPxeenJt19PJStMMeb1Em

@f3l1x
f3l1x force-pushed the claude/docker-host-env-var-07o59y branch from 4267ab6 to cc7a90a Compare August 10, 2026 17:15
The rootless Docker setup hardcoded DOCKER_HOST in /etc/profile and in
dockerd-rootless-start, clobbering any value supplied by the environment
(workspace template, docker run -e, mounted host socket, remote daemon).

Both now treat the rootless socket as a fallback only. The startup script
skips starting a daemon when one already answers at DOCKER_HOST, derives
XDG_RUNTIME_DIR from a provided unix .../docker.sock so dockerd and the CLI
agree on the path, and fails with a clear message for non-unix hosts it
cannot serve.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017jPxeenJt19PJStMMeb1Em
@f3l1x
f3l1x force-pushed the claude/docker-host-env-var-07o59y branch from cc7a90a to 2c56d86 Compare August 10, 2026 17:16
@f3l1x
f3l1x merged commit 610d9a1 into master Aug 10, 2026
5 checks passed
@f3l1x
f3l1x deleted the claude/docker-host-env-var-07o59y branch August 10, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants