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
- db
- nginx (Once db container is turned on completely )
- 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
- db container
- nginx (Wait till db container runs completely)
- 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