pwaller / docker-show-context

Show where time is wasted during the context upload of `docker build`
MIT License
335 stars 16 forks source link

Docker build in the README fails #15

Closed petdance closed 3 years ago

petdance commented 3 years ago

The README.md says that I should

docker build -t docker-show-context https://github.com/pwaller/docker-show-context.git

This gives me:

$ docker build -t docker-show-context https://github.com/pwaller/docker-show-context.git
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

I've tried this in my home directory, a temp directory in my home directory, and /tmp, just in case there were problems with existing files or permissions in the way. Same results in all three.

pwaller commented 3 years ago

Interesting :thinking:, what platform are you on? It looks like an issue with the git or docker installation. This used to work. Not sure it's a problem with docker-show-context.

pwaller commented 3 years ago

It works here, git version 2.25.1, docker 19.03.8.

petdance commented 3 years ago
$ docker --version
Docker version 20.10.3, build 48d30b5
$ git --version
git version 1.8.3.1
pwaller commented 3 years ago

@petdance that version of git looks quite old, dating from 2013. I suspect that's why you're seeing this. I suggest getting a more recent version. I don't think there is anything we can change on our side. Essentially this error is coming when docker runs git clone. If you wanted this "fixed" it would have to be fixed in docker or git, but no-one is going to make changes to support such an old git version, I think.

Unfortunately there isn't enough information to figure out what minimum git version you need. I believe it worked with Ubuntu Trusty though, circa 2014, which had git version 1.9.1.

I don't think there is anything more to action here but if you want to report back any more information (e.g. what OS you're on, if you get it working) please do on this ticket. And do report if you have other issues that prevent you from getting this working. All the best!

petdance commented 3 years ago

Understood. You have to draw a line at what you can support.

I've been looking into why my git is so old, and it looks like I've got the most recent one in yum's Centos repo. I wonder why it's so far behind. :-(

Can you tell me what the git clone is that it's trying to execute? I might be able to find the minimum version you need based on that. I would bet that I won't be the only who will have this problem.

petdance commented 3 years ago

Yeah, it looks like EPEL just has old versions of Git, don't know why.

With the new Git, all is well. Thanks for this, it will be a big help in slimming down my images.

pwaller commented 3 years ago

At a guess, looks like it is submodule update --depth [0], which seems to be supported since git 1.8.4 [1].

[0] https://github.com/moby/moby/blob/d5209b29b9777e0b9713d87847a5dc8ce9d93da6/builder/remotecontext/git/gitutils.go#L67 [1] git/git@2bb7aface663f4d9f01d08282ee38cf8f636df0d

petdance commented 3 years ago

Ha! It figures I was just a point release behind. :-)