Skip to content
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

MSYS2 in a Windows container #30

Closed
peterbud opened this issue Dec 3, 2016 · 20 comments
Closed

MSYS2 in a Windows container #30

peterbud opened this issue Dec 3, 2016 · 20 comments

Comments

@peterbud
Copy link

peterbud commented Dec 3, 2016

Hi Stefan,

your examples and tips are great help for me.

I'm trying to build a Windows container with MSYS2
I was able to build an image based on windowsservercore. I have created a dockerfile, which downloads and installs 7z, and the latest MSYS2 tar, and extracts it:

FROM microsoft/windowsservercore
# Make sure we're in temp for the downloads
WORKDIR c:/windows/temp

# Switch to PowerShell
SHELL ["powershell", "-command"] 

RUN Invoke-WebRequest -UserAgent 'DockerCI' -outfile 7zsetup.exe http://www.7-zip.org/a/7z1604-x64.exe
RUN Invoke-WebRequest -UserAgent 'DockerCI' -outfile msys2-x86_64-latest.tar.xz http://repo.msys2.org/distrib/msys2-x86_64-latest.tar.xz 


RUN Start-Process .\7zsetup -ArgumentList '/S /D=c:/7zip' -Wait
RUN C:\7zip\7z e msys2-x86_64-latest.tar.xz -Wait
RUN C:\7zip\7z x msys2-x86_64-latest.tar -o"C:\\" 
RUN del *

#ENV PATH C:\msys64\usr\bin;C:\Windows;C:\Windows\System32
ENV MSYSTEM MSYS2

CMD powershell

So far so good. I can run the image with interactive shell - no problem:
docker run -it --rm msys2

Bur when I try to execute a simple command like
C:\msys64\usr\bin\pacman.exe --help

there is no message on the stdout

What is needed to see the stdout for MSYS2 binaries in an interactive shell?

@StefanScherer
Copy link
Owner

Hi @peterbud,

I've created your Docker image and compared running pacman.exe in a container and on the host, inspecting it with Sysinternals Process Monitor. Starting a program and just coming back to the prompt seemed to me like there is missing a DLL or something.

Then I just tried to redirect the output of the command in a container.

PS C:\msys64\usr\bin> .\pacman.exe --help >help.txt
PS C:\msys64\usr\bin> cat help.txt
usage:  pacman <operation> [...]
operations:
    pacman {-h --help}
    pacman {-V --version}
    pacman {-D --database} <options> <package(s)>
    pacman {-F --files}    [options] [package(s)]
    pacman {-Q --query}    [options] [package(s)]
    pacman {-R --remove}   [options] <package(s)>
    pacman {-S --sync}     [options] [package(s)]
    pacman {-T --deptest}  [options] [package(s)]
    pacman {-U --upgrade}  [options] <file(s)>

use 'pacman {-h --help}' with an operation for available options

So, the binaries start, but does not show anything in the console.
You should contact the msys2 project to file an issue there.

I've seen an issue about ConEmu inside a Windows container Maximus5/ConEmu#829, they also have problems.

As the process running inside a container must be forwarded to a real shell (or in my case a remote Mac terminal) this may cause problems reading the terminal size etc.

@StefanScherer
Copy link
Owner

Interesting enough is when you add a line before the CMD in your Dockerfile

RUN C:\msys64\usr\bin\pacman.exe --help

and then build the Docker image you see the output:

Step 11/12 : RUN C:\msys64\usr\bin\pacman.exe --help
 ---> Running in e217ee4cca3f
usage:  pacman <operation> [...]
operations:
    pacman {-h --help}
    pacman {-V --version}
    pacman {-D --database} <options> <package(s)>
    pacman {-F --files}    [options] [package(s)]
    pacman {-Q --query}    [options] [package(s)]
    pacman {-R --remove}   [options] <package(s)>
    pacman {-S --sync}     [options] [package(s)]
    pacman {-T --deptest}  [options] [package(s)]
    pacman {-U --upgrade}  [options] <file(s)>

use 'pacman {-h --help}' with an operation for available options

@StefanScherer
Copy link
Owner

Also running without pseudo TTY (-t option) works, but with -t nothing appears.

$ docker run msys2 C:\\msys64\\usr\\bin\\pacman.exe --help
usage:  pacman <operation> [...]
operations:
    pacman {-h --help}
    pacman {-V --version}
    pacman {-D --database} <options> <package(s)>
    pacman {-F --files}    [options] [package(s)]
    pacman {-Q --query}    [options] [package(s)]
    pacman {-R --remove}   [options] <package(s)>
    pacman {-S --sync}     [options] [package(s)]
    pacman {-T --deptest}  [options] [package(s)]
    pacman {-U --upgrade}  [options] <file(s)>

use 'pacman {-h --help}' with an operation for available options
~/code/dockerfiles-windows/msys2 on master
$ docker run -t msys2 C:\\msys64\\usr\\bin\\pacman.exe --help

@StefanScherer
Copy link
Owner

So if you want to build something inside a Dockerfile it could work, only the interactive mode doesn't work.

@StefanScherer
Copy link
Owner

Same directly on my Win2016 Docker host with Docker 1.13.0-rc2 installed

PS C:\> docker run msys2 c:\msys64\usr\bin\pacman.exe --help
usage:  pacman <operation> [...]
operations:
    pacman {-h --help}
    pacman {-V --version}
    pacman {-D --database} <options> <package(s)>
    pacman {-F --files}    [options] [package(s)]
    pacman {-Q --query}    [options] [package(s)]
    pacman {-R --remove}   [options] <package(s)>
    pacman {-S --sync}     [options] [package(s)]
    pacman {-T --deptest}  [options] [package(s)]
    pacman {-U --upgrade}  [options] <file(s)>

use 'pacman {-h --help}' with an operation for available options
PS C:\> docker run -t msys2 c:\msys64\usr\bin\pacman.exe --help
PS C:\>

@StefanScherer
Copy link
Owner

There was a problem with MSYS2 with docker login and the interactive terminal, which was fixed in moby/moby#22956, but this is only for a fix outside the container.
Don't know if the -t should be investigated more in the docker cli/docker engine code.

@peterbud
Copy link
Author

peterbud commented Dec 3, 2016

Hi @StefanScherer , thanks for looking into the issue wit an expert eye.

You actually gave an idea to me, if I set up the MSYS2 environment with the dockerfile, I could use it to build packages as I originally intended.

Nevertheless the pseudo tty seems not to work perfectly yet.

I guess the same issue is present if you try to put a Git for Windows in a container, as it is also using MSYS2 shell.

@StefanScherer
Copy link
Owner

I'll close this issue as it cannot be fixed in this repo. Feel free comment your results :-)

@peterbud
Copy link
Author

peterbud commented Dec 5, 2016

Hi Stefan,

finally I had some time to test this in my environment. Ineterstingly, it was not working for me:

having an interactive session:

PS C:\msys64\usr\bin> .\pacman.exe --help >help.txt
PS C:\msys64\usr\bin> cat help.txt
PS C:\msys64\usr\bin>

Also adding to the docker file resulted an error:

Step 11/12 : RUN C:\msys64\usr\bin\pacman.exe --help
 ---> Running in 0c97f69cc201
The command 'powershell -command C:\msys64\usr\bin\pacman.exe --help' returned a non-zero code: 1

Maybe we are working with different versions of docker?

>docker version
Client:
 Version:      1.13.0-rc2
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   1f9b3ef
 Built:        Wed Nov 23 17:40:58 2016
 OS/Arch:      windows/amd64

Server:
 Version:             1.13.0-rc2
 API version:         1.25
 Minimum API version: 1.24
 Go version:          go1.7.3
 Git commit:          1f9b3ef
 Built:               Wed Nov 23 17:40:58 2016
 OS/Arch:             windows/amd64
 Experimental:        false

Which version you were using?

@StefanScherer
Copy link
Owner

I'm using the same version. Which version is your base image?

docker run microsoft/windowsservercore powershell -command '$(gp ''HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'').BuildLabEx'

for me it's 14393.447

PS C:\> docker run microsoft/windowsservercore powershell -command '$(gp ''HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'').BuildLabEx'
14393.447.amd64fre.rs1_release_inmarket.161102-0100

@StefanScherer
Copy link
Owner

StefanScherer commented Dec 5, 2016

To update the base images, just run

docker pull microsoft/windowsservercore
docker pull microsoft/nanoserver

@peterbud
Copy link
Author

peterbud commented Dec 5, 2016

This is misterious. I have the same version. Nevertheless I have tried to update the base image, but it confirms that it is the same.

Using:

docker pull microsoft/windowsservercore

Using default tag: latest
latest: Pulling from microsoft/windowsservercore
Digest: sha256:571381e3e11fb93ba128adbdcaeb354cb6a470ee60919b89627731361b021d6e
Status: Image is up to date for microsoft/windowsservercore:latest

What is your docker host? I'm running docker on a WIndows 10 Pro v1607

@peterbud
Copy link
Author

peterbud commented Dec 5, 2016

So, I run the same dockerscript on my Azure Windows Server 2016 with containers machine - and it works there, just as in your case, so it has to do something with the docker host being Windows 10.

Am I right the best way to submit an issue to the docker team?

@StefanScherer
Copy link
Owner

I'm stressing conference WiFi to pull windowsservercore :-) I'll try to reproduce on Windows 10.

@StefanScherer
Copy link
Owner

Stuck at 2,4GB + the already downloaded Windows update layer.

PS C:\vagrant\resources\msys> docker build -t msys .
Sending build context to Docker daemon  2.56 kB
Step 1/12 : FROM microsoft/windowsservercore
latest: Pulling from microsoft/windowsservercore
9c7f9c7d9bc2: Downloading 2.487 GB/3.738 GB
d33fff6043a1: Download complete

After retrying it begins to download from zero. Oh, it would be helpful if these downloads would continue to get it through flaky networks.

PS C:\vagrant\resources\msys> docker build -t msys .
Sending build context to Docker daemon  2.56 kB
Step 1/12 : FROM microsoft/windowsservercore
latest: Pulling from microsoft/windowsservercore
9c7f9c7d9bc2: Downloading 10.81 MB/3.738 GB
d33fff6043a1: Downloading 5.947 MB/878.9 MB

@peterbud
Copy link
Author

peterbud commented Dec 5, 2016

Let me know if you can confirm the same with Windows 10 Pro host, then I'll open an issue at the docker repository

@StefanScherer
Copy link
Owner

Couldn't download it today. The best would be filing an issue in docker/for-win if you're using D4Win beta 31

@peterbud
Copy link
Author

peterbud commented Dec 6, 2016

Done

@louisn
Copy link

louisn commented May 25, 2017

I have a use case for git in a Windows 10 Pro Docker Container. ssh and ssh utilities do not operate. Inspecting the container event log shows a crash occured in msys-2.0.dll (below). Any idea if there is a solution or workaround?

ProviderName : Application Error
Id : 1000
Message : Faulting application name: ssh-keygen.EXE, version: 0.0.0.0, time stamp: 0x0005dac8
Faulting module name: msys-2.0.dll, version: 2008.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0000000000113bc5

@filipesilva
Copy link

Just wanted to mention for reference purposes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants