MSYS2-packages
MSYS2-packages copied to clipboard
MSYS2 programs do not output to console inside interactive TTY Windows Docker container
Heya,
I'm trying to setup MSYS2 inside a Windows Docker container, and it looks like there might be a problem between interactive TTY docker sessions and MSYS program output. The original issue I found for this problem is https://github.com/docker/for-win/issues/262.
You can reproduce this by following these steps:
- Install Docker for Windows: https://docs.docker.com/docker-for-windows/. I was using version 18.06.1-ce-win73 (19507)
- Install MSYS2. I used msys2-x86_64-20180531.exe from https://github.com/msys2/msys2/wiki/MSYS2-installation, and installed it to
C:\msys64
. - Open
cmd.exe
and runcd C:\
to go into the root - Running "echo hello" in bash in the host system directly works:
C:\>C:\msys64\usr\bin\bash.exe -c "echo hello"
hello
- Running "echo hello" in bash in a non-interactive container works:
C:\>docker run --rm -v C:\msys64:C:\msys64 stefanscherer/node-windows:10.13.0-build-tools C:\msys64\usr\bin\bash.exe -c "echo hello"
hello
- Running "echo hello" in bash in a interactive non-TTY (
-i
flag) container works (it prints the command as well but that's not related to MSYS2):
C:\Users\kamik>docker run --rm -i -v C:\msys64:C:\msys64 stefanscherer/node-windows:10.13.0-build-tools cmd
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\>C:\msys64\usr\bin\bash.exe -c "echo hello"
C:\msys64\usr\bin\bash.exe -c "echo hello"
hello
- But running it inside an interactive TTY (
-it
flag) container shows no output. If I pipe the output to a file I can see it though.
C:\>docker run --rm -it -v C:\msys64:C:\msys64 stefanscherer/node-windows:10.13.0-build-tools cmd
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\>C:\msys64\usr\bin\bash.exe -c "echo hello"
C:\>C:\msys64\usr\bin\bash.exe -c "echo hello" > debug.txt
C:\>type debug.txt
hello
In https://github.com/docker/for-win/issues/262#issuecomment-311845385 it was mentioned that this behaviour might be related to how MSYS2 uses stdio pipes, but I don't know if this is accurate.
I hope this is somehow fixable between MSYS2 and Docker, and thanks for the good work in MSYS2!
Any progress with this defect?
I do not face this issue on Windows Server 2019 1809 with Docker 19.03:
PS C:\Users\Administrator> [System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 17763 0
PS C:\Users\Administrator> docker version
Client: Docker Engine - Enterprise
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: f660560464
Built: 07/25/2019 20:59:52
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Enterprise
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.24)
Go version: go1.12.5
Git commit: f660560464
Built: 07/25/2019 20:57:41
OS/Arch: windows/amd64
Experimental: false
PS C:\Users\Administrator> docker run --rm -it abrarov/windows-dev:2.8.0 C:\msys64\usr\bin\bash.exe -c "echo hello"
hello
PS C:\Users\Administrator> docker run --rm abrarov/windows-dev:2.8.0 C:\msys64\usr\bin\bash.exe --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
But I reproduce this issue with Windows Server 2016 1607 and Docker 17.06:
PS C:\Users\Administrator> [System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 14393 0
PS C:\Users\Administrator> docker version
Client:
Version: 17.06.2-ee-23
API version: 1.30
Go version: go1.10.8
Git commit: f9a8679
Built: Tue Jul 16 16:47:38 2019
OS/Arch: windows/amd64
Server:
Engine:
Version: 17.06.2-ee-23
API version: 1.30 (minimum version 1.24)
Go version: go1.10.8
Git commit: f9a8679
Built: Tue Jul 16 16:55:49 2019
OS/Arch: windows/amd64
Experimental: false
PS C:\Users\Administrator> docker run --rm -it abrarov/windows-dev:2.5.0 C:\msys64\usr\bin\bash.exe -c "echo hello"
PS C:\Users\Administrator> docker run --rm abrarov/windows-dev:2.5.0 C:\msys64\usr\bin\bash.exe --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
I have to use different docker images for these tests because different versions of Windows require different version of base docker image (mcr.microsoft.com/windows/servercore:ltsc2019 vs microsoft/windowsservercore:ltsc2016)
IMHO, this issue is related to Windows Containers, i.e. is fixed in Windows Server 2019 but won't be fixed in Windows Server 2016, because it doesn't look like MS cares about Windows Containers for Windows Server 2016.
Taking into account the fact that on Windows Server 2016 application inside container is just killed when container stops (docker stop), I do not see possibility to use Windows Containers (docker) on Windows Server 2016. This issue is fixed in Windows Server 2019.
If I'm correct with my findings (if smbd could confirm the same), then I vote for closing this issue as issue not related to MSYS2, but related to Windows Containers in Windows Server 2016.
@mabrarov I had a break-through. It seems like it's broken if I use mcr.microsoft.com/dotnet/framework/sdk:latest as a base image.
This image has the .net framework 4.8 and build tools 2019 installed. It would seem like the most appropriate image to use for CI for windows applications.
In case it helps someone debug this: I have this same behavior (no console output) when my dotnet app is run from MSYS's zsh. Running the app from bash works fine.
@fralalonde it happens to me too with normal bash and zsh when using windows terminal
If I use the Mintty terminal that comes with the msys2 isntaller the output works
For reference, this is how I start msys2 from windows terminal
{
"commandline": "C:/msys64/msys2_shell.cmd -defterm -no-start -mingw64",
"guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d115}",
"name": "bash",
"startingDirectory": "%USERPROFILE%"
},