0

I am having three container , db , nginx and app . I need to turn on container in particular order to make sure things works without any issue.

Order of container is

  1. db
  2. nginx (Once db container is turned on completely )
  3. app (Once db container is turned on Nginx localhost is responding)

I tried using depends on and healthcheck of docker-compose , I couldn't successful

version: "3.3"

services:
  db:
    image: ubuntu:latest
    container_name: db
    build:
      context: ./
      dockerfile: Dockerfile.db
 nginx:
    image: ubuntu:latest
    container_name: nginx
    healthcheck:
      test: curl --noproxy '*' https://localhost --insecure;
    depends_on
      db:
        condition: service_started
    build:
      context: ./
      dockerfile: Dockerfile.nginx
 app:
    image: ubuntu:latest
    container_name: ubuntu
    build:
      context: ./
      dockerfile: Dockerfile.app
    depends_on:
      nginx:
        condition: service_healthy
      db:
        condition: service_started

Let me know what changes , I need to do so that it will run in correct order as mentioned before

  1. db container
  2. nginx (Wait till db container runs completely)
  3. app ( wait till db and nginx runs and nginx responds to https://localhost)

I have tried the multiple answers which are present , still I am not able to fix this issue .

I am observing app running initially only as it's an exe before nginx and db container running

Sreevathsabr
  • 649
  • 7
  • 23

0 Answers0