@@ -24,6 +24,7 @@ import (
24
24
25
25
"github.com/compose-spec/compose-go/loader"
26
26
"github.com/compose-spec/compose-go/types"
27
+ "github.com/mattn/go-isatty"
27
28
"github.com/mattn/go-shellwords"
28
29
"github.com/spf13/cobra"
29
30
@@ -132,7 +133,7 @@ func runCommand(p *projectOptions, backend compose.Service) *cobra.Command {
132
133
flags .StringArrayVarP (& opts .environment , "env" , "e" , []string {}, "Set environment variables" )
133
134
flags .StringArrayVarP (& opts .labels , "labels" , "l" , []string {}, "Add or override a label" )
134
135
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" )
136
137
flags .StringVar (& opts .name , "name" , "" , " Assign a name to the container" )
137
138
flags .StringVarP (& opts .user , "user" , "u" , "" , "Run as specified username or uid" )
138
139
flags .StringVarP (& opts .workdir , "workdir" , "w" , "" , "Working directory inside the container" )
@@ -147,6 +148,10 @@ func runCommand(p *projectOptions, backend compose.Service) *cobra.Command {
147
148
return cmd
148
149
}
149
150
151
+ func notAtTTY () bool {
152
+ return ! isatty .IsTerminal (os .Stdout .Fd ())
153
+ }
154
+
150
155
func runRun (ctx context.Context , backend compose.Service , project * types.Project , opts runOptions ) error {
151
156
err := opts .apply (project )
152
157
if err != nil {
0 commit comments