docker-archive / toolbox

The Docker Toolbox
https://docker.com/toolbox
3.21k stars 1.23k forks source link

Use mintty for the windows "Docker Quickstart Terminal" shortcut #323

Open fungos opened 8 years ago

fungos commented 8 years ago

The current terminal uses git-bash.exe to launch the console and run the script start.sh. This console fallbacks to the basic cmd.exe where there are plenty of limitations (like window resizing, copy-paste, scrolling, etc.).

A better alternative would skip the git-bash.exe wrapper shipped with Git for windows and going directly to the alternative console that git for windows uses internally.

This console is called mintty.exe and it is an implementation based on putty to replace cmd.exe. This console fixes all these annoying problems and enables more customization.

The fix is very simple, only need to run this way (the installer should take care of the hard-coded paths obviously):

"C:\Program Files\Git\usr\bin\mintty.exe" -i "c:\Program Files\Docker Toolbox\docker-quickstart-terminal.ico" /usr/bin/bash --login -i  "c:\Program Files\Docker Toolbox\start.sh"
fungos@fungos-w7  ~
$ uname -a
MSYS_NT-6.1 fungos-w7 2.1.0(0.288/5/3) 2015-06-28 18:57 x86_64 Msys

fungos@fungos-w7  ~
$ docker version
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      windows/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      linux/amd64

fungos@fungos-w7  ~
$ docker info
Containers: 0
Images: 0
Server Version: 1.9.0
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.12-boot2docker
Operating System: Boot2Docker 1.9.0 (TCL 6.4); master : 16e4a2a - Tue Nov  3 19:49:22 UTC 2015
CPUs: 1
Total Memory: 996.2 MiB
Name: default
ID: MYTM:OJ3C:ZEUG:TSDR:7DIP:5EM2:C7XR:UYC2:OGV6:6ZHA:WO3F:XUBF
Debug mode (server): true
 File Descriptors: 11
 Goroutines: 18
 System Time: 2015-11-21T03:49:59.701972393Z
 EventsListeners: 0
 Init SHA1:
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=virtualbox

fungos@fungos-w7  ~
shawnbon206 commented 8 years ago

I agree, on my install Docker Quickstart was opening in cmd.exe. I am already using mintty for other things and I want Docker Quickstart to use it too. The git-for-windows installer has an option to use cmd.exe or mintty, maybe the Docker Toolbox installer can have a similar option?

thbley commented 8 years ago

I'm doing this on Win10 and Console2:

@echo off docker-machine.exe start default docker-machine.exe env --shell=cmd default >%temp%\docker_env.bat %temp%\docker_env.bat

docker run ...

jmorganca commented 8 years ago

Thanks for the issue!

forevermatt commented 8 years ago

I made the change recommended above, going from... "C:\Program Files\Git\bin\bash.exe" --login -i "C:\Program Files\Docker Toolbox\start.sh" ... to... "C:\Program Files\Git\usr\bin\mintty.exe" -i "c:\Program Files\Docker Toolbox\docker-quickstart-terminal.ico" /usr/bin/bash --login -i "c:\Program Files\Docker Toolbox\start.sh" ... as the target of my Docker Quickstart Terminal shortcut. However, something about that seems to cause stdin to not be considered a tty. (I might not be using these terms correctly... please forgive me and feel free to correct my usage as necessary.)

For example, when I run docker run --rm -it api bash (where api is one of the items in my docker-compose.yml file), the result is cannot enable tty mode on non tty input. However, if I try the same command using the orignal (Git-Bash based) Docker QuickStart Terminal, it actually tries to run the command.

It's quite possible that something about my environment is non-standard, and that most users won't have this problem. It just seemed worth mentioned so that someone else could at least verify whether this seems to be a common issue.

smohr003 commented 8 years ago

I have the same issue. Also, note that there are problems with arrow keys in both terminals.

fungos commented 8 years ago

try to put a winpty before the command: winpty docker run --rm -it api bash I have no idea why this happens, but seem pretty common on windows, check: https://github.com/docker/toolbox/issues/136

SvenDowideit commented 8 years ago

ya - I also get

$ docker run --rm -it debian bash
cannot enable tty mode on non tty input

without adding winpty now.

and sadly, if you use winpty in the other terminals, that also breaks.

cosmoslx commented 8 years ago

same issue +1, expect to see mintty to work well

abhilashak commented 8 years ago

For better docker terminal use ConEmu

ConEmu is opensource console emulator with tabs, which represents multiple consoles and simple GUI applications as one customizable GUI window.

Download it from: http://www.fosshub.com/ConEmu.html

Install it. Open the terminal from the windows home button. It will ask 'to which program this terminal should bind?'. Select 'docker quick start terminal', click save.

Start the ConEmut terminal. Enjoy the docker terminal with ConEmu. :)

wclr commented 8 years ago

Why docker command present does not work outside of Quickstart Terminal? (tries to connect to localhost, but not VM)

keski commented 8 years ago

I don't think this comment belongs in this issue, instead have a look at the command: eval $(docker-machine env default)

stubobis1 commented 8 years ago

docker login does not work in mintty:

bash-4.3$ docker login Error: Cannot perform an interactive login from a non TTY device

winpty works though.

BenHizak commented 7 years ago

This problem still occurs, I tried

environment Windows 10 x64

KingGeneral commented 7 years ago

work fine in git bash. (windows : git)

NOTES : for those who cannot login in windows you can use manual command promt like "cmd" (windows : cmd) if get error you can try this one https://github.com/docker/docker/issues/22338

amarouane-ABDELHAK commented 6 years ago

winpty docker run -it ubuntu bash

anhcuong commented 6 years ago

I use git-sdk from here: https://github.com/git-for-windows/build-extra/releases and I am able to run with winpty. The below command works fine

alias dr="winpty docker run dr -it -p 80:80 nginx

dean-luka commented 6 years ago

Instead of using aliases you can put: exec winpty bash on the end of you .profile - first bash is replaced by new bash behind winpty so every program that you run inside git-bash will find proper tty - which means python will work also, and docker run/login/attach

Since i'm using same git shell for everything (docker, ansible, chef, vagrant, terraform, ...) it's important that it works fine (and looks fine - no scrollbar, shift up/down/pageup/down, alt enter to full screen, ... :-).

And you don't even have to press ctrl-d twice when you want to exit, just once cause first shell is replaced with second.

I tried to put winpty in windows shortcut but it didn't work, here is command "C:\Program Files\Git\usr\bin\winpty.exe" "C:\Program Files\Git\git-bash.exe" --cd-to-home It opens two windows, and second one doesn't get proper tty (first one is dead).

PlamenVasilev commented 6 years ago

On git bash just type: alias docker="winpty docker" and tty will work

akshaysin commented 6 years ago

Another Approach, do a docker login from powershell and then use git-bash

rattfieldnz commented 4 years ago

I made the change recommended above, going from... "C:\Program Files\Git\bin\bash.exe" --login -i "C:\Program Files\Docker Toolbox\start.sh" ... to... "C:\Program Files\Git\usr\bin\mintty.exe" -i "c:\Program Files\Docker Toolbox\docker-quickstart-terminal.ico" /usr/bin/bash --login -i "c:\Program Files\Docker Toolbox\start.sh" ... as the target of my Docker Quickstart Terminal shortcut. However, something about that seems to cause stdin to not be considered a tty. (I might not be using these terms correctly... please forgive me and feel free to correct my usage as necessary.)

For example, when I run docker run --rm -it api bash (where api is one of the items in my docker-compose.yml file), the result is cannot enable tty mode on non tty input. However, if I try the same command using the orignal (Git-Bash based) Docker QuickStart Terminal, it actually tries to run the command.

It's quite possible that something about my environment is non-standard, and that most users won't have this problem. It just seemed worth mentioned so that someone else could at least verify whether this seems to be a common issue.

Sorry for commenting on such an old post... I wanted to to the same thing as suggested in the thread title. This thread post got me the desired results (host machine is Windows 10 Home).