通过Windows docker文件设置git [英] Setup git via windows docker file

查看:288
本文介绍了通过Windows docker文件设置git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了Dockerfile,它基于 windowsnanoserver .我需要添加到此图像git.为了实现它,我做了以下工作:

I write Dockerfile which is based on windowsnanoserver. I need to add to this image git. In order to achieve it I did the following:

RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/Git-2.12.2.2-64-bit.exe'
RUN Invoke-Expression "c:\Git-2.12.2.2-64-bit.exe"

但是当我通过docker build执行此行时,我收到以下错误消息:

But when I execute this lines via docker build, I receive following error message:

Invoke-Expression:术语'c:\ Git-2.12.2.2-64-bit.exe'不是 识别为cmdlet,函数,脚本文件或可操作文件的名称 程序.检查名称的拼写,或者是否包含路径, 验证路径正确无误,然后重试.

Invoke-Expression : The term 'c:\Git-2.12.2.2-64-bit.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我意识到此错误消息表明,由于Windows docker映像的控制台性质,我将无法执行GUI安装程序.不幸的是git没有控制台安装程序. 巧克力.为了为 windowsnanoserver 安装git,我想在Dockerfile命令中重复来自巧克力git安装程序,对我来说很好,但我仍然想知道那里在 windowsnanoserver 上安装git的简单方法?

I realize that this error message indicates that due to console nature of windows docker images I'll not be able to execute GUI installers. Unfortunately git doesn't have console installer. Chocolatey works fine under windowsservercore image but doesn't work at windowsnanoserver. In order to install git for windowsnanoserver I have idea to repeat in Dockerfile commands from chocolatey git installer which is fine for me, but still I'd like to know is there any simpler way to install git on windowsnanoserver?

推荐答案

我已经通过使用MinGit并将有关mingit的信息放入环境/路径变量中,解决了GUI问题.我使用了以下方法:

I've solved issue with GUI through usage of MinGit and by putting information about mingit into environment/path variable. I've used following approach:

RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip' -OutFile MinGit.zip

RUN Expand-Archive c:\MinGit.zip -DestinationPath c:\MinGit; \
$env:PATH = $env:PATH + ';C:\MinGit\cmd\;C:\MinGit\cmd'; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

这篇关于通过Windows docker文件设置git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆