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

236
Visualizações
why container api launching after the container containing my script

I have a docker compose launching 2 containers. Problem is that it seems that my container with the api that I need to reach from the other container start only after and then I have a request issue.

version: "3.9"
services:
  fastapi:
    container_name: my-api
    image: fastapi:latest
    networks:
      - my-network
    ports: 
      - target: 8000
        published: 8000
        mode: host
  authentification:
    container_name: authentification
    networks:
      - my-network
    image: authentification:latest
    volumes:
      - .:/home/log_folder
    depends_on:
      - "fastapi"

networks:
  my-network:

Th containers can communicate together as If I launch manually the container with the script authentification after the api is started, it works.

Any clue ?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I finally added a time.sleep at he beginning of each of my container with script reaching the api to ensure they wait the api is launched. This is not a big issue as these scripts are just test script to check authentification etc ...

Thanks !

over 4 years ago · Santiago Trujillo Relatório

0

Dependency checks only container startup, not service. time.sleep is a crutch, actually. Just add healthcheck block to your fastapi service

fastapi:
  healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:8000"]
    interval: 1s
    timeout: 2s
    retries: 10

and change dependency block to this:

authentification:
  depends_on:
    fastapi:
      condition: service_healthy
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