Docker 构建 GitHub 存储库并推送到 DockerHub

Docker Build a GitHub Repository and Push to DockerHub

我有一个 GitHub 存储库,它在项目根目录中有一个 Dockerfile。我想构建存储库,但遇到错误。

命令运行(Dockerfile位于存储库根目录中,在main分支中)

$ docker build https://github.com/$RepoOwner/$RepositoryName.git#main:.
$ docker build https://github.com/$RepoOwner/$RepositoryName.git#main:

两者都会产生以下错误:

unable to prepare context: unable to 'git clone' to temporary context directory: error initializing submodules: usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
   or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] init [--] [<path>...]
   or: git submodule [--quiet] deinit [-f|--force] [--] <path>...
   or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
   or: git submodule [--quiet] foreach [--recursive] <command>
   or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
: exit status 1

我通过克隆 Git 存储库然后 运行 docker 在其上构建解决了这个问题。