From c6dd6f9d7f16c471a4ffa04d488dd5be97ee78a2 Mon Sep 17 00:00:00 2001 From: Florian Bender Date: Fri, 16 Oct 2015 14:49:03 +0200 Subject: [PATCH] Add switch to override the default Docker hostname (fixes #193) A new (optional) ENV var was added to the templates that instructs the `launcher` script to use the DISCOURSE_HOSTNAME as the Docker hostname (via the -h/--hostname option) instead of the default value of `$hostname-$config`. --- launcher | 20 +++++++++++++++++++- samples/standalone.yml | 4 ++++ samples/web_only.yml | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/launcher b/launcher index 8f412f9..d2fefdf 100755 --- a/launcher +++ b/launcher @@ -502,10 +502,28 @@ run_start(){ set_run_image set_boot_command + # get hostname and settings from container configuration + for envar in "${env[@]}" + do + if [[ $envar == DOCKER_USE_HOSTNAME* ]] || [[ $envar == DISCOURSE_HOSTNAME* ]] + then + # use as environment variable + eval $envar + fi + done + ( hostname=`hostname` + # overwrite hostname + if [ "$DOCKER_USE_HOSTNAME" = "true" ] + then + hostname=$DISCOURSE_HOSTNAME + else + hostname=$hostname-$config + fi + set -x - $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname-$config" \ + $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname" \ -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command ) diff --git a/samples/standalone.yml b/samples/standalone.yml index 0547265..e45532d 100644 --- a/samples/standalone.yml +++ b/samples/standalone.yml @@ -64,6 +64,10 @@ env: ## TODO: The domain name this Discourse instance will respond to DISCOURSE_HOSTNAME: 'discourse.example.com' + ## TODO: Uncomment if you want the container to be started with the same + ## hostname (-h option) as specified above (default "$hostname-$config") + ## NOTE: 'true' is the only valid value here, any other will be ignored + #DOCKER_USE_HOSTNAME: true ## TODO: The mailserver this Discourse instance will use DISCOURSE_SMTP_ADDRESS: smtp.example.com # (mandatory) diff --git a/samples/web_only.yml b/samples/web_only.yml index 142fddf..35acb5f 100644 --- a/samples/web_only.yml +++ b/samples/web_only.yml @@ -42,6 +42,10 @@ env: ## ## TODO: The domain name this Discourse instance will respond to DISCOURSE_HOSTNAME: 'discourse.example.com' + ## TODO: Uncomment if you want the container to be started with the same + ## hostname (-h option) as specified above (default "$hostname-$config") + ## NOTE: 'true' is the only valid value here, any other will be ignored + #DOCKER_USE_HOSTNAME: true ## ## TODO: The mailserver this Discourse instance will use DISCOURSE_SMTP_ADDRESS: smtp.example.com # (mandatory) -- 2.25.1