Compare commits

...

5 Commits

Author SHA1 Message Date
Pascal Vizeli
306df2e6b8
Merge 2470d16d85fe2643a050927aec2a125ad6e5ef50 into 4c108eea6411df12e9292e4171c1ca2c8d8b129f 2025-02-17 13:48:31 +01:00
Pascal Vizeli
2470d16d85 Cleanup 2022-08-09 14:36:56 +00:00
Pascal Vizeli
5c0172440a change name 2022-08-09 11:18:33 +00:00
Pascal Vizeli
006db94cc0 fix gateway 2022-08-09 08:32:16 +00:00
Pascal Vizeli
9f1ab99265 Support basic IPv6 2022-08-09 08:07:52 +00:00
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},
)