简体   繁体   中英

Openresty Docker container when try RUN, return nginx: invalid option: “/bin/sh”

I try build an imagen with openresty:centos and the imagen is Successfully built, but when try tu RUN a container with this image the container STOP ans show this message:

nginx: invalid option: "/bin/sh"

FROM openresty/openresty:1.11.2.3-centos

RUN yum install openssl-devel -y

RUN /usr/local/openresty/luajit/bin/luarocks install lua-cjson
RUN /usr/local/openresty/luajit/bin/luarocks install lua-resty-jwt
RUN /usr/local/openresty/luajit/bin/luarocks install lua-resty-redis
RUN /usr/local/openresty/luajit/bin/luarocks install luacrypto
RUN /usr/local/openresty/luajit/bin/luarocks install lualogging
RUN /usr/local/openresty/luajit/bin/luarocks install luaposix
RUN /usr/local/openresty/luajit/bin/luarocks install uuid

RUN PATH=/usr/local/openresty/nginx/sbin:$PATH
RUN export PATH

COPY ./src/api-gw/conf/nginx.conf /usr/local/openresty/nginx/conf

COPY ./src/api-gw/lib/authentication.lua /usr/local/openresty/lualib
COPY ./src/api-gw/lib/logger.lua /usr/local/openresty/lualib
COPY ./src/api-gw/lib/redis.lua /usr/local/openresty/lualib
COPY ./src/api-gw/lib/uses_cases.lua /usr/local/openresty/lualib
COPY ./src/api-gw/lib/utils.lua /usr/local/openresty/lualib

RUN mkdir /home/app

COPY ./src/api-gw/api-gw.lua /home/app

EXPOSE 80

CMD nginx -p /usr/local/openresty/nginx -c nginx.conf

command for build image:

docker build -t openresty_test .

command for RUN a container:

docker run -it -p 8888:80 --name img_resty openresty_test

response:

nginx: invalid option: "/bin/sh"

According to Dockerfile , you should override ENTRYPOINT rather than CMD . See Docker documentation for details.

ENTRYPOINT and CMD are combined, so you are actually trying to execute:

$ /usr/local/openresty/bin/openresty -g 'daemon off;' /bin/sh -c 'nginx -p /usr/local/openresty/nginx -c nginx.conf'
nginx: invalid option: "/bin/sh"

I would also recommend you to use exec form of CMD / ENTRYPOINT ( ["executable","param1","param2"] , not executable param1 param2 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM