docker / cli

The Docker CLI
Apache License 2.0
4.74k stars 1.88k forks source link

Handle networks.driver_opts for a service #5125

Closed robmry closed 4 weeks ago

robmry commented 4 weeks ago

- What I did

Handle networks.driver_opts for a service.

Related to:

These are endpoint-specific driver options...

services:
  myservice:
    networks:
      mynet:
        driver_opts:
          "option1": "value1"

The API has had support for a long time, it's only recently been added to compose (unreleased right now).

- How I did it

Updated verification schema, add ServiceNetworkConfig.DriverOpts, passed the opts to swarm, and updated tests.

- How to verify it

Updated tests.

With this config:

services:
  foo:
    image: alpine
    command: sleep infinity
    networks:
      mynet:
        driver_opts:
          "com.docker.network.endpoint.sysctls": "net.ipv6.conf.IFNAME.accept_ra=1"

networks:
  mynet:
    name: mynet

Ran docker stack deploy --compose-file compose.yml foo ... checked that the option appeared in the container's inspect output, and the sysctl was updated in the container.

- Description for the changelog

Added support to `docker stack deploy` for `driver_opts` in a service's networks, in new version 3.13 of its compose schema.
codecov-commenter commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 61.35%. Comparing base (9b61bbb) to head (94f9de5). Report is 5 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5125 +/- ## ========================================== - Coverage 61.37% 61.35% -0.03% ========================================== Files 298 295 -3 Lines 20717 20717 ========================================== - Hits 12715 12710 -5 - Misses 7102 7104 +2 - Partials 900 903 +3 ```