Ver Fonte

Merge pull request #25216 from aanand/deploy-error-when-not-in-swarm-mode

Better error on 'docker deploy' when not in Swarm mode
Michael Crosby há 9 anos atrás
pai
commit
2a10899c16
1 ficheiros alterados com 8 adições e 0 exclusões
  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
 		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)
 	networks := getUniqueNetworkNames(bundle.Services)
 	ctx := context.Background()
 	ctx := context.Background()