     agentUrl = if options?.targetHost then "http://#{options.targetHost}" else pickAgent()
 
     # replace deprecated parameter substition
-    def = (findAppDef app, version).dockerCompose
-    def = def.replace (new RegExp "\{\{", 'g'), '_#_'
-    def = def.replace (new RegExp "\}\}", 'g'), '_#_'
+    appDef = (findAppDef app, version)
+    def = appDef.dockerCompose
+    bigboatCompose =  YAML.load  appDef.bigboatCompose
+
+    for key, value of parameters
+      rex = new RegExp "{{#{key}}}", 'g'
+      def = def.replace rex, value
 
     definition = YAML.load def
 

    HTTP.put "#{pickAgent()}/storage?access_token=#{Settings.get('agentAuthToken')}", data: name: destination, source: source


  startApp: (app, version, instance, parameters, options = {}) ->
    unless ApplicationDefs.findOne {name: app, version: version}
      throw new Meteor.Error "Application #{app}:#{version} does not exist"


        'bigboat/agent/url': agentUrl
        'bigboat/startedBy': user._id
        'bigboat/storage/bucket': options.storageBucket
        'bigboat/instance/endpoint': bigboatCompose[serviceName]?.endpoint
        'bigboat/instance/endpoint/protocol': bigboatCompose[serviceName]?.protocol
      service.restart = 'unless-stopped'

    console.log 'xxx', definition
