New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fungos opened this Issue Nov 26, 2015 · 19 comments

Comments

Projects
None yet
@fungos

fungos commented Nov 26, 2015

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

This comment has been minimized.

Show comment
Hide comment
@shawnbon206

shawnbon206 Dec 8, 2015

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?

shawnbon206 commented Dec 8, 2015

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?

@thomasbley

This comment has been minimized.

Show comment
Hide comment
@thomasbley

thomasbley Dec 26, 2015

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 ...

thomasbley commented Dec 26, 2015

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

This comment has been minimized.

Show comment
Hide comment
@jmorganca

jmorganca Jan 8, 2016

Contributor

Thanks for the issue!

Contributor

jmorganca commented Jan 8, 2016

Thanks for the issue!

@jmorganca jmorganca added bug windows and removed bug labels Jan 8, 2016

@forevermatt

This comment has been minimized.

Show comment
Hide comment
@forevermatt

forevermatt Feb 1, 2016

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.

forevermatt commented Feb 1, 2016

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

This comment has been minimized.

Show comment
Hide comment
@smohr003

smohr003 Feb 4, 2016

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

smohr003 commented Feb 4, 2016

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

@fungos

This comment has been minimized.

Show comment
Hide comment
@fungos

fungos Feb 6, 2016

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: #136

fungos commented Feb 6, 2016

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: #136

@SvenDowideit SvenDowideit changed the title from Better default shortcut for windows "Docker Quickstart Terminal" to use mintty for the windows "Docker Quickstart Terminal" shortcut Feb 7, 2016

@SvenDowideit SvenDowideit changed the title from use mintty for the windows "Docker Quickstart Terminal" shortcut to Use mintty for the windows "Docker Quickstart Terminal" shortcut Feb 7, 2016

@SvenDowideit

This comment has been minimized.

Show comment
Hide comment
@SvenDowideit

SvenDowideit Feb 7, 2016

Contributor

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.

Contributor

SvenDowideit commented Feb 7, 2016

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

This comment has been minimized.

Show comment
Hide comment
@cosmoslx

cosmoslx Feb 15, 2016

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

cosmoslx commented Feb 15, 2016

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

@abhilashak

This comment has been minimized.

Show comment
Hide comment
@abhilashak

abhilashak Feb 25, 2016

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. :)

abhilashak commented Feb 25, 2016

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. :)

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Mar 20, 2016

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

whitecolor commented Mar 20, 2016

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

@keski

This comment has been minimized.

Show comment
Hide comment
@keski

keski May 23, 2016

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

keski commented May 23, 2016

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

@stubobis1

This comment has been minimized.

Show comment
Hide comment
@stubobis1

stubobis1 Aug 1, 2016

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.

stubobis1 commented Aug 1, 2016

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.

@gmacario gmacario referenced this issue Feb 21, 2017

Closed

runme.sh: Print initial Jenkins admin password #153

4 of 4 tasks complete
@BenHizak

This comment has been minimized.

Show comment
Hide comment
@BenHizak

BenHizak Apr 7, 2017

This problem still occurs, I tried

  • The built in Docker Quickstart Terminal
  • bash which comes with docker "%DOCKER_TOOLBOX_INSTALL_PATH%\..\Git\usr\bin\bash.exe"-l -i "%DOCKER_TOOLBOX_INSTALL_PATH%\start.sh" -new_console:t:"Docker"
  • windows cmd
  • mintty "C:\Program Files\Git\usr\bin\mintty.exe" (image below)
    image

environment Windows 10 x64

BenHizak commented Apr 7, 2017

This problem still occurs, I tried

  • The built in Docker Quickstart Terminal
  • bash which comes with docker "%DOCKER_TOOLBOX_INSTALL_PATH%\..\Git\usr\bin\bash.exe"-l -i "%DOCKER_TOOLBOX_INSTALL_PATH%\start.sh" -new_console:t:"Docker"
  • windows cmd
  • mintty "C:\Program Files\Git\usr\bin\mintty.exe" (image below)
    image

environment Windows 10 x64

@KingGeneral

This comment has been minimized.

Show comment
Hide comment
@KingGeneral

KingGeneral Apr 8, 2017

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 moby/moby#22338

KingGeneral commented Apr 8, 2017

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 moby/moby#22338

@amarouane-ABDLHAK

This comment has been minimized.

Show comment
Hide comment
@amarouane-ABDLHAK

amarouane-ABDLHAK Nov 22, 2017

winpty docker run -it ubuntu bash

amarouane-ABDLHAK commented Nov 22, 2017

winpty docker run -it ubuntu bash

@anhcuong

This comment has been minimized.

Show comment
Hide comment
@anhcuong

anhcuong Jan 31, 2018

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

anhcuong commented Jan 31, 2018

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

This comment has been minimized.

Show comment
Hide comment
@dean-luka

dean-luka Mar 26, 2018

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).

dean-luka commented Mar 26, 2018

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

This comment has been minimized.

Show comment
Hide comment
@PlamenVasilev

PlamenVasilev Jun 5, 2018

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

PlamenVasilev commented Jun 5, 2018

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

@akshaysin

This comment has been minimized.

Show comment
Hide comment
@akshaysin

akshaysin Jun 19, 2018

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

akshaysin commented Jun 19, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment