From e22e643b375430fc4ca54378cb6cd5cdaeb32e35 Mon Sep 17 00:00:00 2001 From: sonicaj Date: Fri, 20 Dec 2024 20:17:05 +0500 Subject: [PATCH] Reflect configured http proxy in docker (#15248) --- .../middlewared/etc_files/docker/daemon.json.py | 9 +++++++++ .../middlewared/plugins/network_/global_config.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/middlewared/middlewared/etc_files/docker/daemon.json.py b/src/middlewared/middlewared/etc_files/docker/daemon.json.py index 1125035bdc173..a4ee8dc4a4165 100644 --- a/src/middlewared/middlewared/etc_files/docker/daemon.json.py +++ b/src/middlewared/middlewared/etc_files/docker/daemon.json.py @@ -9,6 +9,7 @@ def render(service, middleware): config = middleware.call_sync('docker.config') + http_proxy = middleware.call_sync('network.configuration.config')['httpproxy'] if not config['pool']: raise FileShouldNotExist() @@ -25,6 +26,14 @@ def render(service, middleware): 'storage-driver': 'overlay2', 'fixed-cidr-v6': config['cidr_v6'], 'default-address-pools': config['address_pools'], + **( + { + 'proxies': { + 'http-proxy': http_proxy, + 'https-proxy': http_proxy, + } + } if http_proxy else {} + ) } isolated = middleware.call_sync('system.advanced.config')['isolated_gpu_pci_ids'] for gpu in filter(lambda x: x not in isolated, get_nvidia_gpus()): diff --git a/src/middlewared/middlewared/plugins/network_/global_config.py b/src/middlewared/middlewared/plugins/network_/global_config.py index eb68009b573cd..a74ce9ccbec20 100644 --- a/src/middlewared/middlewared/plugins/network_/global_config.py +++ b/src/middlewared/middlewared/plugins/network_/global_config.py @@ -369,6 +369,9 @@ async def do_update(self, data): {'data': {'httpproxy': new_config['httpproxy']}} ) + if (await self.middleware.call('docker.config'))['pool']: + # Docker needs to be restarted to reflect http proxy changes + service_actions.add(('docker', 'restart')) # allowing outbound network activity has been changed if new_config['activity'] != config['activity']: await self.middleware.call('zettarepl.update_tasks')