linux - 尝试RUN时Openresty Docker容器,返回nginx : invalid option: "/bin/sh"

标签 linux docker nginx lua openresty

我尝试使用 openresty:centos 构建一个图像,图像已成功构建,但是当尝试使用此图像运行容器时,容器停止并显示此消息:

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 documentation了解详情。

ENTRYPOINTCMD 结合在一起,所以你实际上是在尝试执行:

$ /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/ENTRYPOINTexec 形式 (["executable","param1", "param2"],不是可执行的param1 param2)

关于linux - 尝试RUN时Openresty Docker容器,返回nginx : invalid option: "/bin/sh",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56885598/

相关文章:

linux - 如果第 n 列包含特定单词,如何删除行?

Docker 中的 Java GUI Maven 项目出现 X11 错误

java - 警告 session 0x0 服务器为空、意外错误、关闭套接字连接并尝试重新连接

docker - 暴露Docker容器端口不起作用

Android 模拟器启动卡在 “QEMU Pipe Device:rw, wait_event error”

linux - 如何linux命令找到多种类型

php - Unix 命令删除前几行中的空格

docker - Certbot 失败 acme-challenge(连接被拒绝)

nginx - 我丢失了nginx.pid,它消失了

url-rewriting - 使用 NginX 和 Laravel : URL Rewrites