I have a web app in python3
. I'am trying to access the web app from another Machine on my network (cloud environment). The web app works.
The Dockerfile is as follows:
FROM python:3.8.0-slim as builder
RUN apt-get update \
&& apt-get install gcc -y \
&& apt-get clean
COPY app/requirements.txt /app/requirements.txt
WORKDIR app
RUN pip install --upgrade pip && pip3 install --user -r requirements.txt
COPY ./app /app
# Production image
FROM python:3.8.0-slim as app
COPY --from=builder /root/.local /root/.local
COPY --from=builder /app /app
WORKDIR app
ENV PATH=/root/.local/bin:$PATH
EXPOSE 5000
ENTRYPOINT gunicorn main:app -b 0.0.0.0:5000
$docker build -t simu .
$docker run --name simu --detach -p 5000:5000 -it simu:v1
11a8e9e2f7f2d70d39cac2b3e2a14c25ae2bf9536db005dee1d473aa588139ae
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
11a8e9e2f7f2 simu:v1 "/bin/sh -c 'gunicor…" 3 seconds ago Up 3 seconds 0.0.0.0:5000->5000/tcp simu
$curl -X POST {} http://localhost:5000
curl: (3) <url> malformed
curl: (56) Recv failure: Connection reset by peer
Why I receive that error?
UPDATE
If I run the container as
/usr/bin/docker run --name simu --detach --network host -e REGISTRAR_URL=http://localhost:8500 -it simu:v1
The service is accessible from the same machine:
curl -X POST {} http://localhost:5000
curl: (3) <url> malformed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
But it is not from another machine on the same LAN:
$curl -X POST http://algo:5000/generate-prod
curl: (7) Failed connect to algo:5000; Connection refused
I have stopped firewalld also. If I run the application without the container everything works, so I think there must be something in the neworking with docker which is not set correctly.