Support rootless podman via a Docker-compatible client helper - #9
Open
jiezhuzzz wants to merge 1 commit into
Open
Support rootless podman via a Docker-compatible client helper#9jiezhuzzz wants to merge 1 commit into
jiezhuzzz wants to merge 1 commit into
Conversation
cybergym reaches the container runtime through `docker.from_env()`, which only locates a Docker daemon. On hosts running rootless podman there is no Docker socket, so the scoring server and firewall proxy cannot reach the runtime. Add `cybergym.utils.get_docker_client()`, resolving the API endpoint as: 1. `$DOCKER_HOST` if set (honored verbatim by `docker.from_env`) 2. `/var/run/docker.sock` if present (standard Docker) 3. `$XDG_RUNTIME_DIR/podman/podman.sock` (podman's Docker-compatible API) falling back to `docker.from_env()` otherwise. Route the three `docker.from_env()` call sites (`server_utils.run_container`, `server_utils.run_container_binary`, `firewall.proxy.FirewallProxyManager`) through it. Docker users are unaffected (they still hit `from_env`); rootless-podman users no longer need to set `DOCKER_HOST` by hand. The `docker` import is lazy so `utils.py` stays importable without the optional `docker` dependency.
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.
Motivation
cybergym reaches the container runtime through
docker.from_env(), which only locates a Docker daemon. On hosts running rootless podman there is no Docker socket at the default path, socybergym.server(running PoCs) and the firewall proxy fail to connect to the runtime. Today users have to manually exportDOCKER_HOSTpointing at podman's socket.Change
Add
cybergym.utils.get_docker_client(), which resolves the container API endpoint as:$DOCKER_HOSTif set (honored verbatim bydocker.from_env)/var/run/docker.sockif present (standard Docker)$XDG_RUNTIME_DIR/podman/podman.sock— podman serves a Docker-compatible API there, so the same code runs unchanged under rootless podmanfalling back to
docker.from_env()otherwise (so its usual connection error still surfaces).The three
docker.from_env()call sites are routed through it:server/server_utils.py—run_container,run_container_binaryfirewall/proxy.py—FirewallProxyManager.__init__Notes
DOCKER_HOST//var/run/docker.sockpresent) the behavior is identical todocker.from_env().dockerimport inside the helper is lazy, socybergym.utils(e.g.get_arvo_id) stays importable without the optionaldockerdependency installed.+32 / -6across 3 files; passes the repo'sruffconfig.from_env; rootless podman socket present →DockerClient(unix://…/podman.sock); nothing present →from_envfallback).