diff options
author | Christian Breunig <christian@breunig.cc> | 2023-02-28 22:17:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 22:17:45 +0100 |
commit | 36cf6ea9a1c86de1352ceef9b0fd8088f1e53a44 (patch) | |
tree | dbe3e10a4770f2e400ea51594c6bd1fdaed01541 /src/conf_mode/container.py | |
parent | 9b88a68001b79583cc2be59b4d6e1af3bed4aecf (diff) | |
parent | c68d73e6720a7df2b48df17ac7b9b4c906e0294c (diff) | |
download | vyos-1x-36cf6ea9a1c86de1352ceef9b0fd8088f1e53a44.tar.gz vyos-1x-36cf6ea9a1c86de1352ceef9b0fd8088f1e53a44.zip |
Merge pull request #1860 from sever-sever/T4967
T4967: Allow setting container hostname
Diffstat (limited to 'src/conf_mode/container.py')
-rwxr-xr-x | src/conf_mode/container.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index 4f93c93a1..10e9e9213 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -256,6 +256,11 @@ def generate_run_arguments(name, container_config): for k, v in container_config['environment'].items(): env_opt += f" --env \"{k}={v['value']}\"" + hostname = '' + if 'host_name' in container_config: + hostname = container_config['host_name'] + hostname = f'--hostname {hostname}' + # Publish ports port = '' if 'port' in container_config: @@ -277,7 +282,7 @@ def generate_run_arguments(name, container_config): container_base_cmd = f'--detach --interactive --tty --replace {cap_add} ' \ f'--memory {memory}m --shm-size {shared_memory}m --memory-swap 0 --restart {restart} ' \ - f'--name {name} {device} {port} {volume} {env_opt}' + f'--name {name} {hostname} {device} {port} {volume} {env_opt}' entrypoint = '' if 'entrypoint' in container_config: @@ -285,6 +290,11 @@ def generate_run_arguments(name, container_config): entrypoint = json_write(container_config['entrypoint'].split()).replace('"', """) entrypoint = f'--entrypoint '{entrypoint}'' + hostname = '' + if 'host_name' in container_config: + hostname = container_config['host_name'] + hostname = f'--hostname {hostname}' + command = '' if 'command' in container_config: command = container_config['command'].strip() |