无法在Docker容器中使用fig / crane执行git命令
我使用起重机来协调我的容器,并且我的项目资源(一个NodeJS应用程序)有一个git子模块。 当我尝试在我的项目根目录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
这是我的crane.yml
configuration文件:
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
这是我的fig.yml
db: build: images/db web: build: images/web volumes: - src/web:/src links: - db:mongo ports: - "8000:8000"
奇怪的是当我在当前目录(例如../myproject
)设置我的卷。 但我真的需要在我的仓库中有一个子模块
编辑
如果我使用命令行,它不起作用。 所以它不涉及无花果或起重机,但也许是如何Docker,凉亭或混帐工作。
注意
- 我在Archlinux上
- 我也试图用Docker fig ,它会产生相同的错误
谢谢你的帮助 !
当你使用git submodule
,你会发现一个指向git目录的.git
文件,就像这样:
gitdir: ../../.git/modules/src/web
当你启动一个Docker容器时,你的.git
文件没有.git/
文件夹,所以当容器在子模块中启动一个git
命令时,它会尝试访问不可访问的git对象。
解决scheme
临时重命名.git
文件或不使用git submodule
如果您在docker container
中使用git submodule
并运行git或bower,则find此问题的解决scheme。 在你的Dockerfile
,放置以下内容来修复git引用:
# git submodules reference fix ENV GIT_DIR=/path/to/git/submodule