dlayer
dlayer copied to clipboard
Proposed enhancement: search function
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
grepfor example does)