Skip to content

Support rootless podman via a Docker-compatible client helper - #9

Open
jiezhuzzz wants to merge 1 commit into
sunblaze-ucb:mainfrom
jiezhuzzz:podman-compat
Open

Support rootless podman via a Docker-compatible client helper#9
jiezhuzzz wants to merge 1 commit into
sunblaze-ucb:mainfrom
jiezhuzzz:podman-compat

Conversation

@jiezhuzzz

Copy link
Copy Markdown

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, so cybergym.server (running PoCs) and the firewall proxy fail to connect to the runtime. Today users have to manually export DOCKER_HOST pointing at podman's socket.

Change

Add cybergym.utils.get_docker_client(), which resolves the container 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 serves a Docker-compatible API there, so the same code runs unchanged under rootless podman

falling 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.pyrun_container, run_container_binary
  • firewall/proxy.pyFirewallProxyManager.__init__

Notes

  • Non-breaking for Docker users: with no podman socket (or with DOCKER_HOST//var/run/docker.sock present) the behavior is identical to docker.from_env().
  • The docker import inside the helper is lazy, so cybergym.utils (e.g. get_arvo_id) stays importable without the optional docker dependency installed.
  • +32 / -6 across 3 files; passes the repo's ruff config.
  • Verified the resolution branches locally (DOCKER_HOST set → from_env; rootless podman socket present → DockerClient(unix://…/podman.sock); nothing present → from_env fallback).

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.
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