77 "github.com/docker/docker/cli"
88 "github.com/docker/docker/cli/command"
99 "github.com/spf13/cobra"
10+ "github.com/spf13/pflag"
1011 "golang.org/x/net/context"
1112)
1213
@@ -22,7 +23,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
2223 if len (args ) > 1 {
2324 opts .args = args [1 :]
2425 }
25- return runCreate (dockerCli , opts )
26+ return runCreate (dockerCli , cmd . Flags (), opts )
2627 },
2728 }
2829 flags := cmd .Flags ()
@@ -58,7 +59,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
5859 return cmd
5960}
6061
61- func runCreate (dockerCli * command.DockerCli , opts * serviceOptions ) error {
62+ func runCreate (dockerCli * command.DockerCli , flags * pflag. FlagSet , opts * serviceOptions ) error {
6263 apiClient := dockerCli .Client ()
6364 createOpts := types.ServiceCreateOptions {}
6465
@@ -104,5 +105,14 @@ func runCreate(dockerCli *command.DockerCli, opts *serviceOptions) error {
104105 }
105106
106107 fmt .Fprintf (dockerCli .Out (), "%s\n " , response .ID )
107- return nil
108+
109+ if opts .detach {
110+ if ! flags .Changed ("detach" ) {
111+ fmt .Fprintln (dockerCli .Err (), "Since --detach=false was not specified, tasks will be created in the background.\n " +
112+ "In a future release, --detach=false will become the default." )
113+ }
114+ return nil
115+ }
116+
117+ return waitOnService (ctx , dockerCli , response .ID , opts )
108118}
0 commit comments