Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

593
Views
Unable to connect to flask while running on docker container

I am trying to move a simple flask application to docker, but I can't see to figure out why the application is not accessible from the browser.

docker-compose file

version: '3'
services:
  web:
    build: .
    ports:
     - "5000:5000"
    volumes:
      - .:/app
    environment:
      FLASK_APP: api
      FLASK_ENV: development

  redis:
    image: "redis:alpine"

dockerfile

FROM python:3.7

ADD . /app
WORKDIR /app

RUN pip install -r requirements.txt
CMD ["flask", "run"]

__init__py:

def create_app(test_config=None):
  app = Flask(__name__, instance_relative_config=True)
  ...

  return app

result from docker-compose up --build

web_1    |  * Serving Flask app "api" (lazy loading)
web_1    |  * Environment: development
web_1    |  * Debug mode: on
web_1    |  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
web_1    |  * Restarting with stat
web_1    |  * Debugger is active!
web_1    |  * Debugger PIN: 277-205-758

But when I got to the browser:

The connection was reset

enter image description here

Any ideas why? I can't see what I am missing because the server is running but it does reset the connection right away...

Edit:

  • I did try to access it via localhost, 0.0.0.0, also using the container IP address
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try

CMD ["flask", "run", "--host=0.0.0.0"]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!