gitcontainersdockerbowergit-submodules

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). When I run up my containers when it tries to bower install in my project root this error occurs:

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:

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

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. 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.

Note

Thanks for your help !


Solution

  • As your using git submodule, you will find a .git file referring to the git directory, something like that:

    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.

    The solution

    Rename the .git file temporarly or not using git submodule