Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda