   list = (containerDetails[item] for item in depTree.resolve())
 
   callback list
+
+validateContainerPresence = (list, done) ->
+  iterator = (details, callback) ->
+    name = details.name
+    container = docker.getContainer name
+    container.inspect callback
+
+  async.eachSeries list, iterator, done

      @start cluster, done

    stop: (done) ->
      [container] = @args
      @stop container, done

    cluster: (done) ->
      [method, cluster] = @args
      switch method
        when "start" then @cluster_start cluster, done
        when "stop" then @cluster_stop cluster, done

    status: (done) ->
      child_process.exec "docker ps", (err, stdout, stderr) ->


    resolveOrder @config, target, (list) ->

      validateContainerPresence list, (err) ->
        return done err if err

        async.eachSeries list, (details, callback) ->
          name = details.name
          container = docker.getContainer name
          container.inspect (err, data) ->
            if not data.State.Running
              log "Starting container #{name}"
              container.start callback
            else
              log "Container #{name} already running..."
              callback null
        , done


  stop: (cluster, done) ->
    throw new Error "Please supply a cluster to stop" if not cluster

    target = @config.clusters[cluster]

    throw new Error "Cluster #{cluster} does not exist in decking.json"  if not target

    resolveOrder @config, target, (list) ->

      validateContainerPresence list, (err) ->
        return done err if err

        async.eachSeries list, (details, callback) ->
          name = details.name
          container = docker.getContainer name
          container.inspect (err, data) ->
            if data.State.Running
              log "Stopping container #{name}"
              container.stop callback
            else
              log "Container #{name} is not running..."
              callback null
        , done

  create: (container, done) ->
    # @TODO use the remote API when it supports -name and -link
