docker-openresty icon indicating copy to clipboard operation
docker-openresty copied to clipboard

Use ENTRYPOINT + CMD for easier configurability

Open ambis opened this issue 4 years ago • 1 comments

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;

ambis avatar Jul 02 '20 22:07 ambis

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.

neomantra avatar Jul 09 '20 00:07 neomantra