How to correctly initialize git submodules in Dockerfile for Docker Cloud How to correctly initialize git submodules in Dockerfile for Docker Cloud docker docker

How to correctly initialize git submodules in Dockerfile for Docker Cloud


See the answer I gave here: https://stackoverflow.com/a/59640438/1021344

Reproduced here for simplicity:You need to use hooks: https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks

TL;DR: Place this in hooks/post_checkout:

#!/bin/bash# Docker hub does a recursive clone, then checks the branch out,# so when a PR adds a submodule (or updates it), it fails.git submodule update --init