I have to "dockerize" a service I'm writing (a small Flask app). This is what I wrote:
FROM python:3
RUN apt-get update && apt-get install -y build-essential
WORKDIR /app
COPY requirements.txt /app
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app
EXPOSE 5000
ENV FLASK_APP=app.py
ENV FLASK_DEBUG=1
CMD flask run
I can build the image and run the container with
docker run -p 5000:5000 <container-name>
and flask tells me it's listening on 127.0.0.1:5000. But I can't access the application from my host machine. I've also tried using the localhost
and 0.0.0.0
as the address. However, if I exec
into the container I can curl
the address to receive the response I expect.
Does anyone know what's going on here?