I have a Flask app that is running within a Docker container (app.run(host="0.0.0.0", port=3000), with EXPOSE 3000 in the Dockerfile. I’m deploying to fly with flyctl deploy --config ./myapp/fly.toml --dockerfile ./myapp/Dockerfile --remote-only -a my-app.
My fly.toml file is
The deploy succeeds but I cannot access my app if I go to myapp.fly.dev, and if I go into the fly console and curl localhost:3000 I get connection refused. What am I doing incorrectly here with the ports?
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] INFO Preparing to run: `python3 hello.py` as root
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] INFO [fly api proxy] listening at /.fly/api
2023-12-15T23:26:10Z app[90806603bd0438] iad [info]2023/12/15 23:26:10 listening on [fdaa:0:d445:a7b:229:74e9:ff44:2]:22 (DNS: [fdaa::3]:53)
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] * Serving Flask app 'hello'
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] * Debug mode: off
2023-12-15T23:26:10Z app[90806603bd0438] iad [info]WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] * Running on all addresses (0.0.0.0)
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] * Running on http://127.0.0.1:3000
2023-12-15T23:26:10Z app[90806603bd0438] iad [info] * Running on http://172.19.3.82:3000
2023-12-15T23:26:10Z app[90806603bd0438] iad [info]Press CTRL+C to quit
You should be able to put the Dockerfile that I gave you into an empty directory and run fly launch. If you do so, the fly.toml you will receive will look something like this:
Can I get you to try this? It is self contained and should work.
At that point there is something different about your app. The problem isn’t in your fly.toml or in your app.run statement. But without seeing your app or the rest of your logs, I can’t speculate as to where that problem is.
I was running two processes in the container. When I moved to individual containers and fly instances for each process, it works (not sure causal reason).