I am trying to run mongodb and Mongo-express containers using docker-compose. Mongo db might take some time to boot up(Up and running). So Mondo-express container should run only after Mondb container is up and running .
Even though am using the "depends_on" tag in mongo-exp, still in a few occasions mongo-exp container building will fail. If I try to recreate the mongo-exp container, it will work.
Please find the docker-compose.yaml
version : "3"
services:
  mongodb:
    container_name: mongodb
    image: mongo
    ports:
    - "27017:27017"
    volumes:
      - "/home/opsmgr/devops/docker_mount:/data/db"
    environment:
      - MONGO_INITDB_ROOT_USERNAME=***
      - MONGO_INITDB_ROOT_PASSWORD=***
    networks:
      - dbpvt
  mongo-exp:
     image: mongo-express
     container_name: mongo-exp
     ports:
      - "8081:8081"
     environment:
       - ME_CONFIG_MONGODB_ADMINUSERNAME=**
       - ME_CONFIG_MONGODB_ADMINPASSWORD=**
       - ME_CONFIG_MONGODB_SERVER=mongodb
       - ME_CONFIG_BASICAUTH_USERNAME=**
       - ME_CONFIG_BASICAUTH_PASSWORD=**
     networks:
       - dbpvt
     depends_on:
      - mongodb
networks:
 dbpvt:**
 
    