Merge 2470d16d85fe2643a050927aec2a125ad6e5ef50 into ad5827d33fcdb448b156edbd492c482df90c2930

This commit is contained in:
Pascal Vizeli 2025-02-18 20:28:49 +01:00 committed by GitHub
commit bd77b12d06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -43,6 +43,7 @@ SYSTEMD_JOURNAL_VOLATILE = Path("/run/log/journal")
DOCKER_NETWORK = "hassio"
DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23")
DOCKER_NETWORK_RANGE = ip_network("172.30.33.0/24")
DOCKER_NETWORK_ULA = ip_network("fd00:172:30:32::/64")
# This needs to match the dockerd --cpu-rt-runtime= argument.
DOCKER_CPU_RUNTIME_TOTAL = 950_000

View File

@ -7,7 +7,12 @@ import logging
import docker
import requests
from ..const import DOCKER_NETWORK, DOCKER_NETWORK_MASK, DOCKER_NETWORK_RANGE
from ..const import (
DOCKER_NETWORK,
DOCKER_NETWORK_MASK,
DOCKER_NETWORK_RANGE,
DOCKER_NETWORK_ULA,
)
from ..exceptions import DockerError
_LOGGER: logging.Logger = logging.getLogger(__name__)
@ -76,19 +81,25 @@ class DockerNetwork:
except docker.errors.NotFound:
_LOGGER.info("Can't find Supervisor network, creating a new network")
ipam_pool = docker.types.IPAMPool(
# IP configuration
ipam_pool_v4 = docker.types.IPAMPool(
subnet=str(DOCKER_NETWORK_MASK),
gateway=str(self.gateway),
iprange=str(DOCKER_NETWORK_RANGE),
)
ipam_pool_v6 = docker.types.IPAMPool(
subnet=str(DOCKER_NETWORK_ULA),
gateway=str(DOCKER_NETWORK_ULA[1]),
)
ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool])
ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool_v4, ipam_pool_v6])
# Create Network
return self.docker.networks.create(
DOCKER_NETWORK,
driver="bridge",
ipam=ipam_config,
enable_ipv6=False,
enable_ipv6=True,
options={"com.docker.network.bridge.name": DOCKER_NETWORK},
)