Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ENTRYPOINT + CMD for easier configurability #146

Open
ambis opened this issue Jul 2, 2020 · 1 comment
Open

Use ENTRYPOINT + CMD for easier configurability #146

ambis opened this issue Jul 2, 2020 · 1 comment

Comments

@ambis
Copy link

ambis commented Jul 2, 2020

Now there is CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"], but it could be

ENTRYPOINT ["/usr/local/openresty/bin/openresty"]
CMD ["-g", "daemon off;"]

And if I want to override the -g argument, I could do just

docker run openresty/openresty:alpine -g "daemon off; env MY_ENV_FOR_LUA;"

Without having to be concerned where the openresty binary resides.

How to verify functionality

Dockerfile

FROM openresty/openresty:alpine

ENTRYPOINT ["/usr/local/openresty/bin/openresty"]
CMD ["-g", "daemon off;"]

Build it

docker build -t test .

Run it

docker run --rm -it -e FOO=bar test -g 'daemon off; env FOO;'

Exec into and see process with top

    {openresty} nginx: master process /usr/local/openresty/bin/openresty -g daemon off; env FOO;
@neomantra
Copy link
Member

Thanks for your suggestion and your demonstration. We used to use ENTRYPOINT, but then a user suggested using CMD. See #51 and #52.

It seems like it could go both ways. I eventually sided with CMD, mostly because that is how the Nginx images work.

I note that your suggestion (versus the old implementation) combines CMD and ENTRYPOINT. This is usually done when the image is intended to always use the same ENTRYPOINT. But, some users invoke other binaries from this image, e.g. resty and luajit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants