diff options
author | Christian Breunig <christian@breunig.cc> | 2023-08-23 20:18:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 20:18:54 +0200 |
commit | b1886e35e5166034f60541cb4a1020c000627b8c (patch) | |
tree | 585d01120d3d0a4af138d755d99df9f14907e3c3 /src | |
parent | a3a78b1cec173b25f080a1f0c549d254abd005b8 (diff) | |
parent | 7822d4f7a22cb316ac10f199bdb1836782ee2c6e (diff) | |
download | vyos-1x-b1886e35e5166034f60541cb4a1020c000627b8c.tar.gz vyos-1x-b1886e35e5166034f60541cb4a1020c000627b8c.zip |
Merge pull request #2161 from sever-sever/T5463
T5463: Container allow publish listen-addresses
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/container.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index ed7cc809c..478868a9a 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -33,6 +33,7 @@ from vyos.utils.process import call from vyos.utils.process import cmd from vyos.utils.process import run from vyos.utils.process import rc_cmd +from vyos.template import bracketize_ipv6 from vyos.template import inc_ip from vyos.template import is_ipv4 from vyos.template import is_ipv6 @@ -280,6 +281,14 @@ def generate_run_arguments(name, container_config): protocol = container_config['port'][portmap]['protocol'] sport = container_config['port'][portmap]['source'] dport = container_config['port'][portmap]['destination'] + listen_addresses = container_config['port'][portmap].get('listen_address', []) + + # If listen_addresses is not empty, include them in the publish command + if listen_addresses: + for listen_address in listen_addresses: + port += f' --publish {bracketize_ipv6(listen_address)}:{sport}:{dport}/{protocol}' + else: + # If listen_addresses is empty, just include the standard publish command port += f' --publish {sport}:{dport}/{protocol}' # Bind volume |