Docker端口转发后浏览器无法访问及Supervisor前台运行配置求助
Hey there! Let's work through your Docker port access issue and get your Supervisor setup sorted for the monitor program.
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:
You should see output showing your app listening onnetstat -tulpn | grep 50000.0.0.0:5000, not just127.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.
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:
- Rebuild your image:
docker-compose build - Restart the container:
docker-compose up -d - Check if Supervisor is managing your processes:
You should see bothdocker exec -it graphql_img_master supervisorctl statusbabelWatchandmonitorlisted asRUNNING.
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

