I've poured over the docs but there's some fundamental piece that I'm still missing.
System:
- mac os 11.2.3
- docker v20.10.5
I have a dumb hello world container in python using Flask in http_server.py
:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'hello world'
The Dockerfile:
FROM python:3.8
WORKDIR /
COPY *.py /
RUN pip install Flask
ENV FLASK_APP=http_server.py
CMD flask run -h localhost -p 80
I build the container:
docker build -t au .
I run the container using port forwarding:
docker run -p 127.0.0.1:8080:80 httptest
I check the container:
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c857400d06ce httptest "/bin/sh -c 'flask r…" 4 minutes ago Up 4 minutes 127.0.0.1:8080->80/tcp busy_feistel
I double check to see there's actually an open socket on the local machine:
$ netstat -an | grep 8080
tcp4 0 0 127.0.0.1.8080 *.* LISTEN
I open the cli in the container to triple check the app is running:
$ docker exec -it c857400d06ce8f2dd88d8466d57c0d274320215e24f2a4610b67d0ee75f8a2ad /bin/sh
# curl 127.0.0.1:80
hello world
Seems like it's all buttoned up! I try to hit the container from my local:
$ curl 127.0.0.1:8080
curl: (52) Empty reply from server
What am I missing? I feel like there is something extremely simple that I'm glossing over, but I've reached the 60-minute mark of searching SO and docker's documentation, so I am throwing in the towel.
Thank you in advance!