I am trying to put a very simple Python API that returns some text and logs the timestamps of sent requests and what not. And if ran on the machine directly, it works fine, but when I try to use it in a Docker, I get no connection of any kind while trying to connect to 127.0.0.1 or localhost.
Here's the Dockerfile
FROM alpine
FROM python
FROM tiangolo/uwsgi-nginx-flask:python3.8
LABEL MAINTAINER="Asd <asd@asd.com"
COPY ./app /app
EXPOSE 5000
ENTRYPOINT ["python3", "/app/main.py"]
I run the container with
docker run --name unicorns -p 127.0.0.1:5000:5000 unicorn-image:latest
Thanks in Advance
EDIT1: Python code
# coding=utf8
import flask,json,sys,socket
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.INFO)
logging.basicConfig(filename='./demo.log', level=logging.INFO)
from datetime import datetime
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
test_date = datetime.now()
app.logger.info('%s', json.dumps(test_date, indent=4, sort_keys=True, default=str))
return "<h1>You are a unicorn!</h1>"
if __name__ == '__main__':
app.run()