Fix interactive run with networking

Make sure we connect the container to all required networks *after*
starting the container and *before* hijacking the terminal.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2016-01-21 18:34:18 +00:00
commit b1ebf5ce17
3 changed files with 8 additions and 6 deletions

View file

@ -41,7 +41,7 @@ from .utils import yesno
if not IS_WINDOWS_PLATFORM:
import dockerpty
from dockerpty.pty import PseudoTerminal
log = logging.getLogger(__name__)
console_handler = logging.StreamHandler(sys.stderr)
@ -709,8 +709,10 @@ def run_one_off_container(container_options, project, service, options):
signals.set_signal_handler_to_shutdown()
try:
try:
dockerpty.start(project.client, container.id, interactive=not options['-T'])
service.connect_container_to_networks(container)
pty = PseudoTerminal(project.client, container.id, interactive=not options['-T'])
sockets = pty.sockets()
service.start_container(container)
pty.start(sockets)
exit_code = container.wait()
except signals.ShutdownException:
project.client.stop(container.id)