[英]Failed to execute git command in Docker container using fig/crane
I use crane to orchestrate my containers and I've got a git submodule for my project sources (a NodeJS app). 我使用起重机来协调容器,并且为项目源(NodeJS应用程序)提供了一个git子模块。 When I run up my containers when it tries to
bower install
in my project root this error occurs: 当我尝试在我的项目根目录中进行
bower install
时运行我的容器时,会发生此错误:
bower jquery#~2.1.1 ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/jquery/jquery.git", exit code of #128
Additional error details:
fatal: Not a git repository: ../../.git/modules/src/web
Here is my crane.yml
config file: 这是我的
crane.yml
配置文件:
containers:
db:
dockerfile: images/db
image: project/db
run:
detach: true
web:
dockerfile: images/web
image: project/web
run:
volume: ["src/web:/src"]
publish: ["8000:8000"]
link: ["db:mongo"]
detach: true
And here is my fig.yml
这是我的
fig.yml
db:
build: images/db
web:
build: images/web
volumes:
- src/web:/src
links:
- db:mongo
ports:
- "8000:8000"
The weird thing is when I set my volume outside the current directory ( ../myproject
for example) it works. 奇怪的是,当我将卷设置为当前目录(例如
../myproject
)之外时,它可以工作。 But I really need to have a submodule in my repository 但是我确实需要在我的存储库中有一个子模块
Edit 编辑
It doesn't work if I use command line. 如果我使用命令行,它将不起作用。 So it's not related to fig or crane but maybe to how Docker, bower or git work.
因此,它与无花果或起重机无关,但可能与Docker,bower或git的工作方式无关。
Note 注意
Thanks for your help ! 谢谢你的帮助 !
As your using git submodule
, you will find a .git
file referring to the git directory, something like that: 在使用
git submodule
,您会找到一个引用git目录的.git
文件,如下所示:
gitdir: ../../.git/modules/src/web
When you launch a Docker container you're putting your .git
file without the .git/
folder so when the container launch a git
command in the submodule, it try to access git objects which are not accessible. 当你启动你把你的码头工人,容器
.git
文件没有.git/
文件夹,以便当容器启动一个git
辅助模块的命令,它试图访问不可访问Git对象。
The solution 解决方案
Rename the .git
file temporarly or not using git submodule
临时重命名
.git
文件或不使用git submodule
Found a solution to this problem if you are using a git submodule
inside a docker container
and running git or bower. 如果您在
docker container
中使用git submodule
并运行git或bower,则找到了解决此问题的方法。 In your Dockerfile
, place the following to fix the git references: 在
Dockerfile
,放置以下内容以修复git引用:
# git submodules reference fix
ENV GIT_DIR=/path/to/git/submodule
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.