mirror of https://github.com/docker/compose.git
Add option to disable pseudo-tty on fig run
Also disable tty if stdin is not a tty.
This commit is contained in:
parent
24a6d1d836
commit
fc1bbb45b1
|
@ -4,7 +4,6 @@ import logging
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import signal
|
import signal
|
||||||
import sys
|
|
||||||
|
|
||||||
from inspect import getdoc
|
from inspect import getdoc
|
||||||
|
|
||||||
|
@ -200,12 +199,20 @@ class TopLevelCommand(Command):
|
||||||
Usage: run [options] SERVICE COMMAND [ARGS...]
|
Usage: run [options] SERVICE COMMAND [ARGS...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d Detached mode: Run container in the background, print new container name
|
-d Detached mode: Run container in the background, print new
|
||||||
|
container name
|
||||||
|
-T Disable pseudo-tty allocation. By default `fig run`
|
||||||
|
allocates a TTY.
|
||||||
"""
|
"""
|
||||||
service = self.project.get_service(options['SERVICE'])
|
service = self.project.get_service(options['SERVICE'])
|
||||||
|
|
||||||
|
tty = True
|
||||||
|
if options['-d'] or options['-T'] or not sys.stdin.isatty():
|
||||||
|
tty = False
|
||||||
|
|
||||||
container_options = {
|
container_options = {
|
||||||
'command': [options['COMMAND']] + options['ARGS'],
|
'command': [options['COMMAND']] + options['ARGS'],
|
||||||
'tty': not options['-d'],
|
'tty': tty,
|
||||||
'stdin_open': not options['-d'],
|
'stdin_open': not options['-d'],
|
||||||
}
|
}
|
||||||
container = service.create_container(one_off=True, **container_options)
|
container = service.create_container(one_off=True, **container_options)
|
||||||
|
@ -217,7 +224,7 @@ class TopLevelCommand(Command):
|
||||||
container.id,
|
container.id,
|
||||||
interactive=True,
|
interactive=True,
|
||||||
logs=True,
|
logs=True,
|
||||||
raw=True
|
raw=tty
|
||||||
) as c:
|
) as c:
|
||||||
service.start_container(container, ports=None)
|
service.start_container(container, ports=None)
|
||||||
c.run()
|
c.run()
|
||||||
|
|
Loading…
Reference in New Issue