浏览代码

Better error on 'docker deploy' when not in Swarm mode

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
Aanand Prasad 9 年之前
父节点
当前提交
aab92ec7ec
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      api/client/stack/deploy.go

+ 8 - 0
api/client/stack/deploy.go

@@ -52,6 +52,14 @@ func runDeploy(dockerCli *client.DockerCli, opts deployOptions) error {
 		return err
 	}
 
+	info, err := dockerCli.Client().Info(context.Background())
+	if err != nil {
+		return err
+	}
+	if !info.Swarm.ControlAvailable {
+		return fmt.Errorf("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.")
+	}
+
 	networks := getUniqueNetworkNames(bundle.Services)
 	ctx := context.Background()