dlayer icon indicating copy to clipboard operation
dlayer copied to clipboard

Proposed enhancement: search function

Open skissane opened this issue 3 years ago • 0 comments

I have a Docker image. There is some path in it (let's call it /usr/bin/foo), but I'm not sure which command in the Dockerfile added that path.

I found a way of doing that, by combining this tool with a one-line Perl script:

docker image save $IMAGE | 
    dlayer -n 999999 |
    perl -ne 'chomp;$query=quotemeta("usr/bin/foo");$cmd=$_ if $_ =~ m/ [\$] /;print "$cmd\n\t$_\n" if m/ $query/;'

Now, while this works, it would be even better if dlayer had some kind of search function, so the Perl script was unnecessary. For example, maybe dlayer -p /usr/bin/foo would just print the layer containing /usr/bin/foo, if any.

That's the basic idea. Some possible elaborations:

  • support patterns (glob, maybe even regex), as opposed to just an exact match
  • distinguish in the command exit code between match found, no match found, and error (like grep for example does)

skissane avatar Oct 17 '22 04:10 skissane