Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

588
Visualizações
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 Respostas
Responde à pergunta

0

Try

CMD ["flask", "run", "--host=0.0.0.0"]
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda