FastAPI container binds to localhost
Summary: The app starts inside the container, but Uvicorn binds to 127.0.0.1. Published ports on the host cannot reach it.
Failure type: container_network_binding
Ecosystem: python
Difficulty: easy

Repository files:
path: Dockerfile
content: FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY main.py .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "8000"]
path: requirements.txt
content: fastapi==0.111.0
uvicorn[standard]==0.30.1
path: main.py
content: from fastapi import FastAPI
app = FastAPI()
@app.get('/health')
def health():
    return {'status': 'ok'}

Failure log:
curl: (56) Recv failure: Connection reset by peer
container log: Uvicorn running on http://127.0.0.1:8000

Build command: docker build -t sabnock/sbd-0012 .
Verify commands:
docker build -t sabnock/sbd-0012 .

Oracle patch:
diff --git a/Dockerfile b/Dockerfile
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,4 +4,4 @@
 RUN pip install --no-cache-dir -r requirements.txt
 COPY main.py .
 EXPOSE 8000
-CMD ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "8000"]
+CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Scoring - must touch:
Dockerfile
Scoring - must contain:
path: Dockerfile
text: 0.0.0.0
Scoring - must not contain: