[GH-ISSUE #63] docker镜像 nginx-ui 永远都无法自启 #1380

Closed
opened 2026-02-27 12:10:10 +03:00 by kerem · 10 comments
Owner

Originally created by @kilvn on GitHub (Jan 9, 2023).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/63

image

如图,多次尝试都一样,必须进容器手动 指定配置文件启动。

Originally created by @kilvn on GitHub (Jan 9, 2023). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/63 ![image](https://user-images.githubusercontent.com/16423601/211248227-66f2ac9c-4ed8-49ba-8b62-24a4cdb34fa8.png) 如图,多次尝试都一样,必须进容器手动 指定配置文件启动。
kerem 2026-02-27 12:10:10 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@0xJacky commented on GitHub (Jan 9, 2023):

无法复现您的问题,请检查 Docker 启动镜像的 ENTRYPOINT 参数是否被覆盖。

<!-- gh-comment-id:1375220646 --> @0xJacky commented on GitHub (Jan 9, 2023): 无法复现您的问题,请检查 Docker 启动镜像的 ENTRYPOINT 参数是否被覆盖。
Author
Owner

@kilvn commented on GitHub (Jan 10, 2023):

image

这是个非常奇怪的问题,我用的laradock,使用 https://www.composerize.com/ 转成compose类型,Dockerfile里面就加了image,其他的是相关扩展,想把php-fpm几个版本注册到Nginx里面

今天试了下是因为注释的第25行的问题,只要取消注释,nginx-ui容器运行后就不会启动,注释以后就正常了

前提是3个容器都启动了 php-fpm php-fpm74 php-fpm56 (容器名),他们的区别就是php版本不同,端口都是9000,在Nginx没什么问题

<!-- gh-comment-id:1376760715 --> @kilvn commented on GitHub (Jan 10, 2023): <img width="1339" alt="image" src="https://user-images.githubusercontent.com/16423601/211470020-90bd2e15-5433-4392-b4c0-384b8b301e8b.png"> 这是个非常奇怪的问题,我用的laradock,使用 https://www.composerize.com/ 转成compose类型,Dockerfile里面就加了image,其他的是相关扩展,想把php-fpm几个版本注册到Nginx里面 今天试了下是因为注释的第25行的问题,只要取消注释,nginx-ui容器运行后就不会启动,注释以后就正常了 前提是3个容器都启动了 php-fpm php-fpm74 php-fpm56 (容器名),他们的区别就是php版本不同,端口都是9000,在Nginx没什么问题
Author
Owner

@0xJacky commented on GitHub (Jan 10, 2023):

方便贴一下 dockerfile的内容吗,我们测试一下

<!-- gh-comment-id:1376781941 --> @0xJacky commented on GitHub (Jan 10, 2023): 方便贴一下 dockerfile的内容吗,我们测试一下
Author
Owner

@0xJacky commented on GitHub (Jan 10, 2023):

也可以手动执行一下 docker logs 看看容器的日志是什么

<!-- gh-comment-id:1376784569 --> @0xJacky commented on GitHub (Jan 10, 2023): 也可以手动执行一下 docker logs 看看容器的日志是什么
Author
Owner

@kilvn commented on GitHub (Jan 10, 2023):

Dockerfile

FROM uozi/nginx-ui:latest

RUN echo "deb https://mirrors.163.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list \
    && echo "deb-src https://mirrors.163.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list \
    && echo "deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list

RUN apt update \
    && apt upgrade -y \
    && apt install -y zsh vim nano telnet coreutils lsof procps

ARG NGINX_PHP_UPSTREAM_CONTAINER=php-fpm
ARG NGINX_PHP_UPSTREAM_PORT=9000

ARG NGINX_PHP74_UPSTREAM_CONTAINER=php-fpm74
ARG NGINX_PHP56_UPSTREAM_CONTAINER=php-fpm56

# Set upstream conf and remove the default conf
RUN echo "upstream php-upstream { server ${NGINX_PHP_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
    && echo "upstream php74-upstream { server ${NGINX_PHP74_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" >> /etc/nginx/conf.d/upstream.conf \
    && echo "upstream php56-upstream { server ${NGINX_PHP56_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" >> /etc/nginx/conf.d/upstream.conf \
    && rm /etc/nginx/conf.d/nginx-ui.conf

EXPOSE 80 443 9100

image

docker-compose.yml

### nginx-ui ##################################################
    nginx-ui:
      build:
        context: ./nginx-ui
        args:
          - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
          - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
          - http_proxy
          - https_proxy
          - no_proxy
      restart: always
      environment:
        - TZ=Asia/Shanghai
      volumes:
        - ./wwwroot:/var/www
        - ./logs/nginx:/var/log/nginx
        - ./nginx/nginx.conf:/etc/nginx/nginx.conf
        - ./nginx/sites:/etc/nginx/sites-available
        - ./nginx/stream:/etc/nginx/stream
        - ./nginx/ssl:/etc/nginx/ssl
        - ./nginx-ui/app.ini:/etc/nginx-ui/app.ini
      ports:
        - "88:9100"
        - "${NGINX_HOST_HTTP_PORT}:80"
        - "${NGINX_HOST_HTTPS_PORT}:443"
      depends_on:
        - php-fpm
        - php-fpm74
        - php-fpm56
      networks:
        - frontend
        - backend

./nginx-ui/app.ini

[server]
HttpPort          = 9100
RunMode           = debug
WebSocketToken    = 
JwtSecret         = xxx
HTTPChallengePort = 9180
Email             = xxx@xxx.com
Database          = nginx_ui
StartCmd          = login
Demo              = false
PageSize          = 10

[nginx_log]
AccessLogPath = /var/log/nginx/access.log
ErrorLogPath  = /var/log/nginx/error.log
<!-- gh-comment-id:1376804869 --> @kilvn commented on GitHub (Jan 10, 2023): ### Dockerfile ``` FROM uozi/nginx-ui:latest RUN echo "deb https://mirrors.163.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list \ && echo "deb-src https://mirrors.163.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list \ && echo "deb https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \ && echo "deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list \ && echo "deb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list RUN apt update \ && apt upgrade -y \ && apt install -y zsh vim nano telnet coreutils lsof procps ARG NGINX_PHP_UPSTREAM_CONTAINER=php-fpm ARG NGINX_PHP_UPSTREAM_PORT=9000 ARG NGINX_PHP74_UPSTREAM_CONTAINER=php-fpm74 ARG NGINX_PHP56_UPSTREAM_CONTAINER=php-fpm56 # Set upstream conf and remove the default conf RUN echo "upstream php-upstream { server ${NGINX_PHP_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \ && echo "upstream php74-upstream { server ${NGINX_PHP74_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" >> /etc/nginx/conf.d/upstream.conf \ && echo "upstream php56-upstream { server ${NGINX_PHP56_UPSTREAM_CONTAINER}:${NGINX_PHP_UPSTREAM_PORT}; }" >> /etc/nginx/conf.d/upstream.conf \ && rm /etc/nginx/conf.d/nginx-ui.conf EXPOSE 80 443 9100 ``` ![image](https://user-images.githubusercontent.com/16423601/211480323-919ce4c4-42b6-4327-a1a0-004290503c9d.png) ### docker-compose.yml ```ymal ### nginx-ui ################################################## nginx-ui: build: context: ./nginx-ui args: - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER} - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT} - http_proxy - https_proxy - no_proxy restart: always environment: - TZ=Asia/Shanghai volumes: - ./wwwroot:/var/www - ./logs/nginx:/var/log/nginx - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./nginx/sites:/etc/nginx/sites-available - ./nginx/stream:/etc/nginx/stream - ./nginx/ssl:/etc/nginx/ssl - ./nginx-ui/app.ini:/etc/nginx-ui/app.ini ports: - "88:9100" - "${NGINX_HOST_HTTP_PORT}:80" - "${NGINX_HOST_HTTPS_PORT}:443" depends_on: - php-fpm - php-fpm74 - php-fpm56 networks: - frontend - backend ``` ### ./nginx-ui/app.ini ``` [server] HttpPort = 9100 RunMode = debug WebSocketToken = JwtSecret = xxx HTTPChallengePort = 9180 Email = xxx@xxx.com Database = nginx_ui StartCmd = login Demo = false PageSize = 10 [nginx_log] AccessLogPath = /var/log/nginx/access.log ErrorLogPath = /var/log/nginx/error.log ```
Author
Owner

@kilvn commented on GitHub (Jan 10, 2023):

或者可以clone我集成的环境

https://github.com/kilvn/laradock/tree/local

checkout local分支

正常启动:

docker-compose up -d php-fpm php-fpm74 php-fpm56 nginx-ui

这个时候nginx-ui 是无法启动的

然后注释掉第25行重新构建 nginx-ui。

docker-compose stop nginx-ui && docker-compose build nginx-ui && docker-compose up -d nginx-ui

这个时候就没问题了,但是nginx host 会因为找不到php-fpm56而启动失败

laradock/nginx-ui/Dockerfile 第25行【php56-upstream】

很奇怪的问题,为什么php74不注释就可以,非要注释php56,如果有空看一下的话非常感谢

<!-- gh-comment-id:1376808718 --> @kilvn commented on GitHub (Jan 10, 2023): 或者可以clone我集成的环境 https://github.com/kilvn/laradock/tree/local checkout local分支 正常启动: ```shell docker-compose up -d php-fpm php-fpm74 php-fpm56 nginx-ui ``` 这个时候nginx-ui 是无法启动的 然后注释掉第25行重新构建 nginx-ui。 ```shell docker-compose stop nginx-ui && docker-compose build nginx-ui && docker-compose up -d nginx-ui ``` 这个时候就没问题了,但是nginx host 会因为找不到php-fpm56而启动失败 laradock/nginx-ui/Dockerfile 第25行【php56-upstream】 很奇怪的问题,为什么php74不注释就可以,非要注释php56,如果有空看一下的话非常感谢
Author
Owner

@kilvn commented on GitHub (Jan 10, 2023):

也可以手动执行一下 docker logs 看看容器的日志是什么

看过logs,nginx-ui没启动的时候没有任何日志的

<!-- gh-comment-id:1376811490 --> @kilvn commented on GitHub (Jan 10, 2023): > 也可以手动执行一下 docker logs 看看容器的日志是什么 看过logs,nginx-ui没启动的时候没有任何日志的
Author
Owner

@kilvn commented on GitHub (Jan 10, 2023):

image

nginx-ui 容器连服务是没问题的,诡异的Dockerfile 25行

<!-- gh-comment-id:1376821607 --> @kilvn commented on GitHub (Jan 10, 2023): ![image](https://user-images.githubusercontent.com/16423601/211484148-4a52df60-9d33-4c61-a96c-a708445eb994.png) nginx-ui 容器连服务是没问题的,诡异的Dockerfile 25行
Author
Owner

@0xJacky commented on GitHub (Jan 10, 2023):

我这边重新部署了一下您的 laradock,也按照上述 issue 的描述进行了测试,复现了上述问题。

github.com/0xJacky/nginx-ui@41ced2ea05/resources/docker/start.sh (L9-L10)

问题在第9行的 nginx,在您的配置下 nginx 无法进入后台运行模式,所以导致第10行的 nginx-ui 启动命令未执行。

麻烦您先测试一下将第9行的 nginx 改为 nginx &,然后直接 restart nginx-ui 的容器,我这边测试是可以正常启动了,如果没有问题的话,下个版本会一起修复。

<!-- gh-comment-id:1377341038 --> @0xJacky commented on GitHub (Jan 10, 2023): 我这边重新部署了一下您的 laradock,也按照上述 issue 的描述进行了测试,复现了上述问题。 https://github.com/0xJacky/nginx-ui/blob/41ced2ea05f188de573b8b39299db5b92e2f9449/resources/docker/start.sh#L9-L10 问题在第9行的 nginx,在您的配置下 nginx 无法进入后台运行模式,所以导致第10行的 nginx-ui 启动命令未执行。 麻烦您先测试一下将第9行的 `nginx` 改为 `nginx &`,然后直接 restart nginx-ui 的容器,我这边测试是可以正常启动了,如果没有问题的话,下个版本会一起修复。
Author
Owner

@kilvn commented on GitHub (Jan 11, 2023):

好的,感谢你花费时间排查问题,respect!

<!-- gh-comment-id:1378113292 --> @kilvn commented on GitHub (Jan 11, 2023): 好的,感谢你花费时间排查问题,respect!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#1380
No description provided.