[英]nginx: invalid option: "off" and entrypoint.sh: : Permission denied
[英]Openresty Docker container when try RUN, return nginx: invalid option: “/bin/sh”
我嘗試使用openresty:centos構建一個imagen,並且該imagen已成功構建,但是當您嘗試使用此圖像運行一個容器時,容器STOP ans顯示以下消息:
nginx:無效選項:“ / 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
用於生成映像的命令:
docker build -t openresty_test .
運行容器的命令:
docker run -it -p 8888:80 --name img_resty openresty_test
響應:
nginx: invalid option: "/bin/sh"
根據Dockerfile ,您應該覆蓋ENTRYPOINT
而不是CMD
。 有關詳細信息,請參見Docker文檔 。
ENTRYPOINT
和CMD
相結合,因此您實際上是在嘗試執行:
$ /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"
我也建議您使用CMD
/ ENTRYPOINT
exec形式 ( ["executable","param1","param2"]
,而不是executable param1 param2
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.