compose-spec / compose-go

Reference library for parsing and loading Compose YAML files
https://compose-spec.io
Apache License 2.0
355 stars 112 forks source link

networks.enable_ipv6: make it optional #637

Closed akerouanton closed 4 months ago

akerouanton commented 4 months ago

This field isn't marked as required in the compose-spec, but it's implemented as a basic bool in this package. This means it automatically defaults to false when not specified.

A recent change was made to Docker Engine to allow users to define a daemon-wide default value for the equivalent API field. Without this change, Compose would always send a value to the Engine API, preventing it from defining its own default value.

See https://github.com/moby/moby/pull/47867.

akerouanton commented 4 months ago

I revendored this PR in docker/compose (see https://github.com/docker/compose/pull/11893) and tested with the following Compose file with a daemon built from moby/moby@master. The daemon was started with and without --default-network-opt=bridge=com.docker.network.enable_ipv6=true. This yielded the expected results (ie. the default network gets IPv6 enabled when the daemon flag is specified).

services:
  netshoot:
    image: nicolaka/netshoot
    command: /bin/sleep infinity
    networks:
      default: {}
      v6enabled: {}
      v6disabled: {}

networks:
  default: {}
  v6enabled:
    enable_ipv6: true
  v6disabled:
    enable_ipv6: false
ndeloof commented 4 months ago

LGTM as this reflects change in the API https://github.com/moby/moby/pull/47867/files#diff-28bc7f6688f2249afb33f1c3b4558c3bf1bfcda87f1b8e385bc8a5f04b8bdfeaL454-R454