Initialising elasticsearch process with already stored templates

Is there a way to store the templates with ES distribution? We are creating dockers for elasticsearch and requires these templates to be applied before a client like fluentd(which is also running inside another docker) may start the communication with any ES node.
We have currently specified a script in CMD of elasticserach's docker file which contains the curl command to apply this template. But since all dockers get installed in a cluster, there occurs a race condition when fluentd start communication with an ES even beore the curl could be executed. Due to this, ES applied default mapping for the docs received from this fluentd instance.

Is there a way to specify some init time in ES config which would delay every ES node to accept new client requests before this timeout is met so that all ES nodes have joined the cluster and templates have been applied. Such behavior should also be desired at time of new index creations(run time index creations) to let all shards/replicas be available before more documents starts coming.

Please provide some ideas on how to handle this.