Fix Docker gateway IP detection for newer Docker versions#196
Fix Docker gateway IP detection for newer Docker versions#196fao89 wants to merge 1 commit intotox-dev:masterfrom
Conversation
Improve gateway IP detection in get_gateway_ip() to handle both legacy and newer Docker API formats: - Try legacy NetworkSettings.Gateway first for backwards compatibility - Fall back to Networks section for newer Docker versions - Iterate through all networks to find any available gateway - Maintain "0.0.0.0" fallback for cases where no gateway is found This resolves issues where newer Docker versions store network information in a different structure than the legacy format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
|
@dcrosta Any chance of this getting reviewed and merged? Happy to help in any way I can. I have a project that uses GitHub Actions runners are currently rolling out Docker 29 (started Feb 9, 2026 — see actions/runner-images#13474), which removed the deprecated top-level This causes tox-docker to crash with: During the rollout, this manifests as flaky failures since some runners have Docker 28 and some have Docker 29. Once the rollout completes, it will be a 100% failure rate for anyone using The |
## Description Added `TOX_DOCKER_GATEWAY` environment variable to the test workflow to work around a `KeyError: 'Gateway'` failure in tox-docker when running on Docker 29+. Docker 29 [removed the deprecated top-level `NetworkSettings.Gateway` key](https://docs.docker.com/engine/release-notes/29/) from the container inspect API. tox-docker 5.0.0 relies on this key and crashes with a `KeyError`. Setting `TOX_DOCKER_GATEWAY=0.0.0.0` bypasses the broken lookup entirely. This became flaky starting Feb 12 as the [Docker 29 rollout](actions/runner-images#13474) to GitHub Actions runners progresses. Once complete, tests will fail 100% of the time without this fix. This workaround can be removed once [tox-docker merges the fix](tox-dev/tox-docker#196). Mirrors the fix applied in [circulation#3045](ThePalaceProject/circulation#3045) and [library-registry#862](ThePalaceProject/library-registry#862). ## Motivation and Context CI test runs are failing intermittently with: ``` tox_docker/plugin.py, line 53, in get_gateway_ip ip = container.attrs["NetworkSettings"]["Gateway"] or "0.0.0.0" KeyError: 'Gateway' ``` ## How Has This Been Tested? - CI will validate that tests pass with the workaround on Docker 29+ runners ## Checklist - [x] I have updated the documentation accordingly. - [x] All new and existing tests passed.
## Description Added `TOX_DOCKER_GATEWAY` environment variable to the test workflow to work around a `KeyError: 'Gateway'` failure in tox-docker when running on Docker 29+. Docker 29 [removed the deprecated top-level `NetworkSettings.Gateway` key](https://docs.docker.com/engine/release-notes/29/) from the container inspect API. tox-docker 5.0.0 relies on this key and crashes with a `KeyError`. Setting `TOX_DOCKER_GATEWAY=0.0.0.0` bypasses the broken lookup entirely. This became flaky starting Feb 12 as the [Docker 29 rollout](actions/runner-images#13474) to GitHub Actions runners progresses. Once complete, tests will fail 100% of the time without this fix. This workaround can be removed once [tox-docker merges the fix](tox-dev/tox-docker#196). Mirrors the fix applied in [library-registry#862](ThePalaceProject/library-registry#862). ## Motivation and Context CI test runs are failing intermittently with: ``` tox_docker/plugin.py, line 53, in get_gateway_ip ip = container.attrs["NetworkSettings"]["Gateway"] or "0.0.0.0" KeyError: 'Gateway' ``` ## How Has This Been Tested? - CI will validate that tests pass with the workaround on Docker 29+ runners ## Checklist - [x] I have updated the documentation accordingly. - [x] All new and existing tests passed.
## Description Added `TOX_DOCKER_GATEWAY` environment variable to the test workflow to work around a `KeyError: 'Gateway'` failure in tox-docker when running on Docker 29+. Docker 29 [removed the deprecated top-level `NetworkSettings.Gateway` key](https://docs.docker.com/engine/release-notes/29/) from the container inspect API. tox-docker 5.0.0 relies on this key and crashes with a `KeyError`. Setting `TOX_DOCKER_GATEWAY=0.0.0.0` bypasses the broken lookup entirely. This became flaky starting Feb 12 as the [Docker 29 rollout](actions/runner-images#13474) to GitHub Actions runners progresses. Once complete, tests will fail 100% of the time without this fix. This workaround can be removed once [tox-docker merges the fix](tox-dev/tox-docker#196). ## Motivation and Context CI test runs on Python 3.14 (and occasionally 3.12/3.13) are failing intermittently with: ``` tox_docker/plugin.py, line 53, in get_gateway_ip ip = container.attrs["NetworkSettings"]["Gateway"] or "0.0.0.0" KeyError: 'Gateway' ``` ## How Has This Been Tested? - CI will validate that tests pass with the workaround on Docker 29+ runners ## Checklist - [x] I have updated the documentation accordingly. - [x] All new and existing tests passed.
Improve gateway IP detection in get_gateway_ip() to handle both legacy and newer Docker API formats:
This resolves issues where newer Docker versions store network information in a different structure than the legacy format.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com