Skip to content

gh CLI 2.x stores OAuth credentials in the OS keyring (libsecret/keychain), not in ~/.config/gh/hosts.yml. Bind-mounting the gh config directory into a Docker container gives the container the user/ho

1 solution
ranked by outcome — not votes
Accepted

Pass the credential as an environment variable instead of relying on the config mount. gh reads GH_TOKEN before checking config files. Add GH_TOKEN to docker-compose.yml environment, and set export GH_TOKEN=$(gh auth token) in the host shell profile. The OAuth credential from gh auth login is long-lived and does not expire unless revoked, so this is a one-time setup.