Skip to content

Honor DOCKER_HOST in get_api_client()#396

Merged
jpcottin merged 1 commit into
google:masterfrom
jpcottin:fix/honor-docker-host
May 15, 2026
Merged

Honor DOCKER_HOST in get_api_client()#396
jpcottin merged 1 commit into
google:masterfrom
jpcottin:fix/honor-docker-host

Conversation

@jpcottin
Copy link
Copy Markdown
Collaborator

Summary

  • Pass DOCKER_HOST through to docker.APIClient(base_url=...). The docker-py SDK's APIClient() constructor reads no env vars (only from_env() does), so emu-docker silently falls back to /var/run/docker.sock on every machine. That's broken for Docker Desktop, podman, and anyone whose daemon socket is elsewhere.
  • Also corrects the malformed fallback URI unix://var/run/docker.sockunix:///var/run/docker.sock (canonical 3-slash form).

Symptom without this fix

docker.errors.DockerException: Error while fetching server API version:
('Connection aborted.', PermissionError(13, 'Permission denied'))

Test plan

  • With DOCKER_HOST=unix:///run/user/1000/podman/podman.sock (rootless podman): emu-docker create <emu.zip> <sysimg.zip> --start builds the image, boots Android 9 (API 28) in the container, adb connect succeeds, sys.boot_completed=1.
  • Without DOCKER_HOST set: behavior unchanged — docker.APIClient(base_url=None) is equivalent to docker.APIClient().

Related

The docker-py SDK's APIClient() constructor does not read DOCKER_HOST;
only from_env() does. Without it, emu-docker silently ignores the env
var and falls back to /var/run/docker.sock, which fails on Docker
Desktop, podman, and anyone whose daemon socket is elsewhere with:

    DockerException: Error while fetching server API version:
    ('Connection aborted.', PermissionError(13, 'Permission denied'))

Pass base_url=os.environ.get("DOCKER_HOST") so the standard env var
contract works. Also corrects the malformed fallback URI
unix://var/run/docker.sock to the canonical
unix:///var/run/docker.sock.
@jpcottin jpcottin merged commit 071c435 into google:master May 15, 2026
2 checks passed
@jpcottin jpcottin deleted the fix/honor-docker-host branch May 15, 2026 03:37
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