I’m new to Flask and Docker.
I wrote a little app using Flask and containerized it in Docker because it uses Ruby partly in subprocess. It worked locally perfectly.
But when I tried to deploy it following this Deploy via Dockerfile article dependably, I got this warning and my browser was not able to display my app though I accessed app’s address.
WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
- 0.0.0.0:8080
Found these processes inside the machine with open listening sockets:
PROCESS | ADDRESSES
-----------------*----------------------------------------
/.fly/hallpass | [fdaa:2:db74:a7b:b4f1:1678:747c:2]:22
My Dockerfile is here:
FROM python:3.11 AS builder
COPY requirements.txt /
RUN pip install --upgrade pip \
&& pip install -r requirements.txt
FROM ruby:3.1.3
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/lib /usr/local/lib
RUN gem update --system \
&& gem install aozora2html
WORKDIR /app
COPY ./ ./
CMD ["python", "app.py"]
And my app is using Waitress for serving like this:
from waitress import serve
app = Flask(__name__)
if __name__ == "__main__":
serve(app, host='0.0.0.0', port=8080)
Or I tried to switch the way to call serving in Dockerfile but got same error:
CMD ["waitress-serve", "--host:'0.0.0.0'", "--port=8080", "app:app"]
I didn’t edit fly.toml at all and am leaving it as is from when it generated.
app = "hidden-wood-9810"
primary_region = "nrt"
[build]
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
My log is here:
Waiting for logs...
2023-08-30T01:43:33.590 app[e286249b927086] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-08-30T01:43:33.599 app[e286249b927086] nrt [info] 2023/08/30 01:43:33 listening on [fdaa:2:db74:a7b:99:3165:6de8:2]:22 (DNS: [fdaa::3]:53)
2023-08-30T01:43:33.601 app[e286249b927086] nrt [info] /usr/local/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /usr/local/bin/python)
2023-08-30T01:43:33.601 app[e286249b927086] nrt [info] /usr/local/bin/python: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.35' not found (required by /usr/local/bin/../lib/libpython3.11.so.1.0)
2023-08-30T01:43:33.601 app[e286249b927086] nrt [info] /usr/local/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/local/bin/../lib/libpython3.11.so.1.0)
2023-08-30T01:43:33.601 app[e286249b927086] nrt [info] /usr/local/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /usr/local/bin/../lib/libpython3.11.so.1.0)
2023-08-30T01:43:33.601 app[e286249b927086] nrt [info] /usr/local/bin/python: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /usr/local/bin/../lib/libpython3.11.so.1.0)
2023-08-30T01:43:34.293 app[6e82996a076687] nrt [info] INFO Main child exited normally with code: 1
2023-08-30T01:43:34.293 app[6e82996a076687] nrt [info] INFO Starting clean up.
2023-08-30T01:43:34.293 app[6e82996a076687] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-08-30T01:43:34.294 app[6e82996a076687] nrt [info] 2023/08/30 01:43:34 listening on [fdaa:2:db74:a7b:b4f0:1856:fa1d:2]:22 (DNS: [fdaa::3]:53)
2023-08-30T01:43:34.596 app[e286249b927086] nrt [info] INFO Main child exited normally with code: 1
2023-08-30T01:43:34.597 app[e286249b927086] nrt [info] INFO Starting clean up.
2023-08-30T01:43:34.597 app[e286249b927086] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-08-30T01:43:34.598 app[e286249b927086] nrt [info] 2023/08/30 01:43:34 listening on [fdaa:2:db74:a7b:99:3165:6de8:2]:22 (DNS: [fdaa::3]:53)
2023-08-30T01:43:35.290 app[6e82996a076687] nrt [info] [ 2.203521] reboot: Restarting system
2023-08-30T01:43:35.390 runner[6e82996a076687] nrt [info] machine has reached its max restart count (10)
2023-08-30T01:43:35.595 app[e286249b927086] nrt [info] [ 2.264524] reboot: Restarting system
2023-08-30T01:43:35.783 runner[e286249b927086] nrt [info] machine did not have a restart policy, defaulting to restart
2023-08-30T01:43:38.414 proxy[6e82996a076687] nrt [info] waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.111314207s so far)
2023-08-30T01:43:38.912 app[e286249b927086] nrt [info] [ 0.037486] PCI: Fatal: No config space access function found
2023-08-30T01:43:39.119 app[e286249b927086] nrt [info] INFO Starting init (commit: 5293a085)...
2023-08-30T01:43:39.136 app[e286249b927086] nrt [info] INFO Preparing to run: `waitress-serve --host:'0.0.0.0' --port=8080 app:app` as root
2023-08-30T01:43:39.143 app[e286249b927086] nrt [info] INFO [fly api proxy] listening at /.fly/api
# repeating
2023-08-30T01:44:48.284 runner[e286249b927086] nrt [info] machine has reached its max restart count (10)
How can I fix this and be able to deploy my app?