@@ -1428,7 +1428,7 @@ async def container_to_args(
14281428 podman_args .extend (["--hostname" , cnt ["hostname" ]])
14291429 if cnt .get ("shm_size" ):
14301430 podman_args .extend (["--shm-size" , str (cnt ["shm_size" ])])
1431- if cnt .get ("stdin_open" ):
1431+ if cnt .get ("tty" ) and cnt . get ( " stdin_open" ):
14321432 podman_args .append ("-i" )
14331433 if cnt .get ("stop_signal" ):
14341434 podman_args .extend (["--stop-signal" , cnt ["stop_signal" ]])
@@ -4078,10 +4078,10 @@ async def compose_run(compose: PodmanCompose, args: argparse.Namespace) -> None:
40784078 compose_run_update_container_from_args (compose , cnt , args )
40794079 # run podman
40804080 podman_args = await container_to_args (compose , cnt , args .detach , args .no_deps )
4081- if not args .detach :
4081+ if args . tty and not args .detach :
40824082 podman_args .insert (1 , "-i" )
4083- if args .rm :
4084- podman_args .insert (1 , "--rm" )
4083+ if args .rm :
4084+ podman_args .insert (1 , "--rm" )
40854085 p = await compose .podman .run ([], "run" , podman_args )
40864086 sys .exit (p )
40874087
@@ -4118,7 +4118,7 @@ def compose_run_update_container_from_args(
41184118 volumes = clone (cnt .get ("volumes" , []))
41194119 volumes .extend (args .volume )
41204120 cnt ["volumes" ] = volumes
4121- cnt ["tty" ] = not args .T
4121+ cnt ["tty" ] = args .tty
41224122 if args .cnt_command is not None and len (args .cnt_command ) > 0 :
41234123 cnt ["command" ] = args .cnt_command
41244124 # can't restart and --rm
@@ -4138,14 +4138,15 @@ async def compose_exec(compose: PodmanCompose, args: argparse.Namespace) -> None
41384138
41394139
41404140def compose_exec_args (cnt : dict , container_name : str , args : argparse .Namespace ) -> list [str ]:
4141- podman_args = ["--interactive" ]
4141+ podman_args = []
41424142 if args .privileged :
41434143 podman_args += ["--privileged" ]
41444144 if args .user :
41454145 podman_args += ["--user" , args .user ]
41464146 if args .workdir :
41474147 podman_args += ["--workdir" , args .workdir ]
4148- if not args .T :
4148+ if args .tty :
4149+ podman_args += ["--interactive" ]
41494150 podman_args += ["--tty" ]
41504151 env = dict (cnt .get ("environment" , {}))
41514152 if args .env :
@@ -4607,11 +4608,16 @@ def compose_run_parse(parser: argparse.ArgumentParser) -> None:
46074608 action = "append" ,
46084609 help = "Bind mount a volume (can be used multiple times)" ,
46094610 )
4610- parser .add_argument (
4611+ tty_parser = parser .add_mutually_exclusive_group (required = False )
4612+ tty_parser .add_argument (
46114613 "-T" ,
4612- action = "store_true" ,
4613- help = "Disable pseudo-tty allocation. By default `podman-compose run` allocates a TTY." ,
4614+ "--no-tty" ,
4615+ dest = "tty" ,
4616+ action = "store_false" ,
4617+ help = "Disable pseudo-TTY allocation (default: auto-detected)" ,
46144618 )
4619+ tty_parser .add_argument ("-t" , "--tty" , dest = "tty" , action = "store_true" , help = argparse .SUPPRESS )
4620+ parser .set_defaults (tty = sys .stdout .isatty ())
46154621 parser .add_argument (
46164622 "-w" ,
46174623 "--workdir" ,
@@ -4645,11 +4651,16 @@ def compose_exec_parse(parser: argparse.ArgumentParser) -> None:
46454651 parser .add_argument (
46464652 "-u" , "--user" , type = str , default = None , help = "Run as specified username or uid"
46474653 )
4648- parser .add_argument (
4654+ tty_parser = parser .add_mutually_exclusive_group (required = False )
4655+ tty_parser .add_argument (
46494656 "-T" ,
4650- action = "store_true" ,
4651- help = "Disable pseudo-tty allocation. By default `podman-compose run` allocates a TTY." ,
4657+ "--no-tty" ,
4658+ dest = "tty" ,
4659+ action = "store_false" ,
4660+ help = "Disable pseudo-TTY allocation (default: auto-detected)" ,
46524661 )
4662+ tty_parser .add_argument ("-t" , "--tty" , dest = "tty" , action = "store_true" , help = argparse .SUPPRESS )
4663+ parser .set_defaults (tty = sys .stdout .isatty ())
46534664 parser .add_argument (
46544665 "--index" ,
46554666 type = int ,
0 commit comments