 (defn- pick-backends
   "Randomly choose docker backend"
   [n]
-  (mapv (fn [ip] {:client (docker/make-client (str ip ":2375"))
-                  :port   (router/generate-host-port ip)})
+  (mapv (fn [host] {:client (docker/make-client host)
+                    :port   (router/generate-host-port (urly/host-of host))})
         (->> (clusters/docker-hosts)
              shuffle
              (take n))))

               :cmd command
               :port-bindings {host-port port})
          upstream (upstream-url cli host-port)]
      {:id id, :host upstream})))

(defn create [app-name user image & {:keys [tag command port ps]}]
  (let [ps (or ps 1)


(defn delete-instances [instances]
  (doseq [i instances]
    (let [{:keys [docker-host id]} i
          cli (docker/make-client docker-host)]
      (container/stop cli id)
      (container/remove cli id))))

