Search code examples
gitdockergithubdocker-composegit-submodules

docker-compose can't use git submodule


I try to build a docker container from git with docker-compose but when I try to do "docker-compose build", it says:

Building network_monitor
ERROR: error initializing submodules: git: 'submodule' is not a git command. See 'git --help'.
: exit status 1

my docker-compose.yml:

version: "3"

services:
    [...(irrelevant services)...]

    network_monitor:
        build: git://github.com/Kruemmelspalter/network_monitor#main
        ports:
            - "10380:80"
        volumes:
            - "./network_monitor/conf:/root/conf"
    [...(irrelevant services)...]

Solution

  • I would first test the same build, using an HTTPS URL, not a git:// one, using a build context (in Dockerfile v2)

    build: 
      context: github.com/Kruemmelspalter/network_monitor#main
      dockerfile: Dockerfile
    

    Or simply:

    build: github.com/Kruemmelspalter/network_monitor#main