You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker端口转发后浏览器无法访问及Supervisor前台运行配置求助

Hey there! Let's work through your Docker port access issue and get your Supervisor setup sorted for the monitor program.

一、Fixing the Docker Port Access Problem

First, let's figure out why you can't reach localhost:5000/graphql or the container IP on port 5000. Here are the key checks and fixes:

1. Critical Typo in Dockerfile

Looking at your Dockerfile, there's a spelling mistake in the Supervisor config path:

COPY supervisord.conf /etc/supercvisor/conf.d/supervisord.conf

That's supercvisor (missing an 'i') instead of supervisor. This means your supervisord.conf isn't being copied to the correct location, so Supervisor isn't loading your program configurations at all. No wonder your app isn't accessible! Fix this line to:

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

2. Verify if Your App is Actually Listening on Port 5000

Even if the port is mapped, if your app isn't listening on 0.0.0.0:5000 (only 127.0.0.1 won't work from outside the container), you won't be able to reach it.

  • Enter the running container:
    docker exec -it graphql_img_master bash
    
  • Install net-tools if needed:
    apt-get update && apt-get install -y net-tools
    
  • Check port listening:
    netstat -tulpn | grep 5000
    
    You should see output showing your app listening on 0.0.0.0:5000, not just 127.0.0.1:5000.

3. Check Container Logs for Startup Errors

Your app might be failing to start silently. Check the container logs:

docker logs graphql_img_master

Look for errors related to npm run babelWatch or npm run monitor—these would indicate why your app isn't running.

4. Confirm Container Status

Make sure your container is actually running:

docker ps

If it's in a restarting or exited state, the logs will tell you why.

二、Configuring Supervisor to Run "run monitor" in the Foreground

Supervisor manages processes best when they run in the foreground. Here's how to adjust your supervisord.conf to ensure the monitor program runs correctly:

Updated supervisord.conf

[supervisord]
nodaemon=true  ; Keeps Supervisor in the foreground (required for Docker)

[program:babelWatch]
command=npm run babelWatch
directory=/usr/src/app  ; Ensures npm runs from your app's root directory
stdout_logfile=/usr/log/supervisor/babelWatch.log
stderr_logfile=/usr/log/supervisor/babelWatch.err.log
autorestart=true  ; Restarts the process if it crashes
redirect_stderr=true  ; Merges stderr into stdout log

[program:monitor]
command=npm run monitor  ; The actual command to start your monitor
directory=/usr/src/app
stdout_logfile=/usr/log/supervisor/monitor.log
stderr_logfile=/usr/log/supervisor/monitor.err.log
autorestart=true
redirect_stderr=true

Post-Fix Verification

After fixing the Dockerfile typo and updating the Supervisor config:

  1. Rebuild your image:
    docker-compose build
    
  2. Restart the container:
    docker-compose up -d
    
  3. Check if Supervisor is managing your processes:
    docker exec -it graphql_img_master supervisorctl status
    
    You should see both babelWatch and monitor listed as RUNNING.

Once all these steps are done, try accessing localhost:5000/graphql again—it should work if everything is set up correctly.

内容的提问来源于stack exchange,提问作者Soundar Raj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:46:51