Skip to content

OAuth login callback unreachable when container runs under podman: isRunningInDocker() doesn't detect podman, so the callback binds the container-internal loopback #4007

Backlog

Description

@dmaraidonis

Describe the bug

When the server runs in a podman container using the OAuth ("login with GitHub") flow with a published fixed callback port — the exact configuration documented in the README's Docker OAuth section, just with podman instead of docker — the browser login always fails:

  1. The authorization page opens and can be approved on github.com.
  2. GitHub then redirects to http://localhost:8085/callback?..., which the browser cannot reach ("This site can't be reached" — connection reset).
  3. The pending tool call eventually fails with github authorization failed: context deadline exceeded.

The cause is that isRunningInDocker() in internal/oauth/env.go does not detect podman containers, so listenCallback() (internal/oauth/flow.go) binds the callback server to 127.0.0.1 inside the container instead of all interfaces. A published port (-p 127.0.0.1:8085:8085) is delivered to the container's eth0, which can never reach the container's internal loopback — hence every connection to the published port is reset while the flow is live.

Detection fails under podman because:

  • podman does not create /.dockerenv (it creates /run/.containerenv instead), and
  • under cgroup v2 + crun, /proc/1/cgroup inside the container is 0::/ and contains neither docker nor containerd.

Affected version

ghcr.io/github/github-mcp-server:latest (image pulled 2026-12-02):

time=2026-12-02T09:59:18.734Z level=INFO msg="starting server" version=v2.2.0

internal/oauth/env.go on current main still only checks /.dockerenv and /proc/1/cgroup.

Steps to reproduce the behavior

  1. Configure an MCP client with the README's Docker OAuth setup, using podman as the container runtime (Fedora 44, rootless podman):
{
  "command": "podman",
  "args": ["run", "-i", "--rm",
    "-p", "127.0.0.1:8085:8085",
    "-e", "GITHUB_OAUTH_CALLBACK_PORT",
    "ghcr.io/github/github-mcp-server"],
  "env": { "GITHUB_OAUTH_CALLBACK_PORT": "8085" }
}
  1. Invoke any tool (e.g. get_me) to trigger the OAuth login, and approve the authorization page in the browser.
  2. The redirect to http://localhost:8085/callback?... fails with "This site can't be reached".
  3. See the tool call fail after the timeout with github authorization failed: context deadline exceeded.

Evidence gathered while the flow was live:

  • Inside the container's network namespace (/proc/<container-pid>/net/tcp), the listener is bound to 0100007F:1F95, i.e. container-internal 127.0.0.1:8085, not 0.0.0.0.
  • From the host, curl http://127.0.0.1:8085/callback gets Connection reset by peer for the entire duration of the flow (pasta/port-forwarding delivers to eth0, not the container loopback).

Expected vs actual behavior

Expected: Under podman with a published fixed callback port, the callback server binds all container interfaces (as it does under Docker), so the published port reaches it and the browser login completes.

Actual: The server believes it is running natively, binds 127.0.0.1 inside the container, and the OAuth callback is unreachable through the published port — browser login can never succeed.

Logs

time=2026-12-02T09:12:32.000Z level=INFO msg="server session connected" session_id=""
time=2026-12-02T09:12:46.124Z level=INFO msg="requesting github authorization via elicitation"

(No further log lines; the tool call later returns github authorization failed: context deadline exceeded.)

Suggested fix

Add podman detection to isRunningInDocker(), e.g. check for /run/.containerenv (created by podman) or honor the container=podman environment variable that podman sets inside containers:

if _, err := os.Stat("/run/.containerenv"); err == nil {
    return true
}

Workaround

Bind-mount a dummy /.dockerenv so the existing detection succeeds:

-v /dev/null:/.dockerenv

With this mount, the callback binds 0.0.0.0 inside the container and the published loopback port works as documented.

Activity

  1. added
    bug
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions