nginx-proxy / docker-gen

Generate files from docker container meta-data
MIT License
4.43k stars 603 forks source link

Docker ENTRYPOINT script logic is buggy #628

Open KetchupBomb opened 3 months ago

KetchupBomb commented 3 months ago

573 added an ENTRYPOINT which invokes command:

https://github.com/nginx-proxy/docker-gen/blob/17143027f107b12d94d9d3530941cd0448e34acc/app/docker-entrypoint.sh#L6

Based on the comments I could follow in the PR(s), it seems like the purpose was to distinguish between executable and non-executable arguments from COMMAND. A problem, I believe, is that the -v flag is a little too liberal in checking what is "executable", and that causes invoking this Docker image to fail on reasonable input.

Consider the following REPL:

$ docker run -it --rm -v /var/run/docker.sock:/tmp/docker.sock:ro --entrypoint ash nginxproxy/docker-gen
$ echo Hello world > template.tmpl

$ docker-gen /template.tmpl 
Hello world

$ /app/docker-entrypoint.sh /template.tmpl 
/app/docker-entrypoint.sh: exec: line 8: /template.tmpl: Permission denied

Invoking docker-gen with just a template works, but going through the ENTRYPOINT script fails. IMO the Docker image ought to be able to be called in this manner.

This logic can be avoided by passing even a single argument to the ENTRYPOINT script:

$ /app/docker-entrypoint.sh -watch /template.tmpl 
Hello world
2024/05/28 07:33:17 Watching docker events
Hello world

But that's just masking what I believe to be incorrect underlying logic. Thanks for considering the issue.