Fix docker daemon failed to set IPv6 gateway

This commit sets "net.ipv6.conf.eth0.accept_ra" to 0 to avoid the
file exists error.
refer to: https://github.com/moby/libnetwork/issues/2455

Change-Id: Ib0d7cec54bc79b3e29a95c298435b007e769e565
This commit is contained in:
wu.chunyang 2023-12-04 15:48:14 +08:00
parent 48439619b5
commit ae27a32a9f
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fix a bug where docker daemon occasionally returns error:
failed to set IPv6 gateway while updating gateway when network_isolation
is enabled.

View File

@ -82,6 +82,8 @@ def _create_container_with_low_level_api(image: str, param: dict) -> None:
host_config_kwargs["privileged"] = param.get("privileged")
if param.get("volumes"):
host_config_kwargs["binds"] = param.get("volumes")
if param.get("sysctls"):
host_config_kwargs["sysctls"] = param.get("sysctls")
host_config = client.create_host_config(**host_config_kwargs)
network_config_kwargs = dict()
@ -161,6 +163,8 @@ def start_container(client, image, name="database",
if network_mode == constants.DOCKER_HOST_NIC_MODE:
create_network(client, constants.DOCKER_NETWORK_NAME)
kwargs["network"] = constants.DOCKER_NETWORK_NAME
# eth0 is the nic name in the database container.
kwargs['sysctls'] = {"net.ipv6.conf.eth0.accept_ra": 0}
return _create_container_with_low_level_api(image, kwargs)
else:
kwargs["network_mode"] = network_mode