Kibana 4.1.2 insists on using localhost:9200 to connect to ES

Hi, guys. Having an odd problem. I am installing Kibana 4.1.2 into a Docker container based on Ubuntu 14.04 LTS. I am installing it as follows:

cd /opt && wget -q &&
tar -zxf kibana-4.1.2-linux-x64.tar.gz &&
rm kibana-4.1.2-linux-x64.tar.gz &&
mv kibana-4.1.2-linux-x64 kibana

On container start I am copying a slightly modified kibana.yml into /opt/kibana/config/. This file has been edited so that the elasticsearch.url property looks like this:

elasticsearch.url: "http://%1:%2"

At container start a sed command is executed to substitute the actual IP and port on which to connect to elasticsearch. The host is set to a public IP of a test cluster, and the port to 9200. I have inspected inside this container and verified that the edits are applied correctly. I have also verified that the es cluster can be reached and queried at that address.

When I start /opt/kibana/bin/kibana I get the following in the log, and the server never becomes responsive on port 5601:

{"name":"Kibana","hostname":"kibana","pid":11,"level":50,"err":"Request error, retrying -- connect ECONNREFUSED","msg":"","time":"2015-10-15T02:45:21.615Z","v":0}
{"name":"Kibana","hostname":"kibana","pid":11,"level":40,"msg":"Unable to revive connection: http://localhost:9200/","time":"2015-10-15T02:45:21.618Z","v":0}
{"name":"Kibana","hostname":"kibana","pid":11,"level":40,"msg":"No living connections","time":"2015-10-15T02:45:21.618Z","v":0}
{"name":"Kibana","hostname":"kibana","pid":11,"level":30,"msg":"Unable to connect to elasticsearch at http://localhost:9200. Retrying in 2.5 seconds.","time":"2015-10-15T02:45:21.620Z","v":0}

The last event is then repeated every 2.5 seconds until shutdown.

The only other details I can add are that, since we're in a docker container kibana is being run as root. That means the kibana.yml file is also owned by root after I copy it in. I have noted that the owner/group of the unpacked archive files is set to staff:501 or something like that. I have no idea if that's correct or not, but I can say that chowning the whole tree to root:root did not seem to have any effect.

Hopefully someone can point me in the right direction here. Thanks a lot!