@@ -24,6 +24,7 @@ import (
2424
2525 "github.com/compose-spec/compose-go/loader"
2626 "github.com/compose-spec/compose-go/types"
27+ "github.com/mattn/go-isatty"
2728 "github.com/mattn/go-shellwords"
2829 "github.com/spf13/cobra"
2930
@@ -132,7 +133,7 @@ func runCommand(p *projectOptions, backend compose.Service) *cobra.Command {
132133 flags .StringArrayVarP (& opts .environment , "env" , "e" , []string {}, "Set environment variables" )
133134 flags .StringArrayVarP (& opts .labels , "labels" , "l" , []string {}, "Add or override a label" )
134135 flags .BoolVar (& opts .Remove , "rm" , false , "Automatically remove the container when it exits" )
135- flags .BoolVarP (& opts .noTty , "no-TTY" , "T" , false , "Disable pseudo-noTty allocation. By default docker compose run allocates a TTY" )
136+ flags .BoolVarP (& opts .noTty , "no-TTY" , "T" , notAtTTY () , "Disable pseudo-noTty allocation. By default docker compose run allocates a TTY" )
136137 flags .StringVar (& opts .name , "name" , "" , " Assign a name to the container" )
137138 flags .StringVarP (& opts .user , "user" , "u" , "" , "Run as specified username or uid" )
138139 flags .StringVarP (& opts .workdir , "workdir" , "w" , "" , "Working directory inside the container" )
@@ -147,6 +148,10 @@ func runCommand(p *projectOptions, backend compose.Service) *cobra.Command {
147148 return cmd
148149}
149150
151+ func notAtTTY () bool {
152+ return ! isatty .IsTerminal (os .Stdout .Fd ())
153+ }
154+
150155func runRun (ctx context.Context , backend compose.Service , project * types.Project , opts runOptions ) error {
151156 err := opts .apply (project )
152157 if err != nil {
0 commit comments