docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

feat: Add gateway_priority support for network endpoints

Open Adithya1331 opened this issue 7 months ago • 0 comments

This pull request introduces support for the gateway_priority parameter, allowing users to specify the gateway selection priority for a container's network endpoint. This feature corresponds to the GwPriority field in the Docker Engine API, available from version 1.48.

Key Changes:

  • docker.types.networks.EndpointConfig:
    • Added gw_priority parameter to the constructor.
    • Includes validation for API version (>= 1.48) and integer type.
  • docker.api.network.NetworkApiMixin.connect_container_to_network:
    • Added optional gw_priority parameter, which is passed to EndpointConfig.
  • docker.api.container.ContainerApiMixin.create_endpoint_config:
    • Added optional gw_priority parameter, allowing create_container to utilize this feature via networking_config.
  • Tests:
    • Added new unit tests (tests/unit/api_network_gw_priority_test.py) for EndpointConfig and the connect_container_to_network method's handling of gw_priority.
    • Updated existing unit tests in tests/unit/api_network_test.py and tests/unit/api_container_test.py.
    • Added new integration tests in tests/integration/api_network_test.py and tests/integration/api_container_test.py to verify functionality against a Docker daemon.
  • Documentation:
    • Updated docstrings for all modified methods and classes to include gw_priority.
    • Added an entry to docs/change_log.md.

This implementation allows users to influence which network endpoint provides the default gateway for a container, as per the Docker API v1.48 specification.

Adithya1331 avatar May 23 '25 17:05 Adithya1331