How can I setup a docker container in docker compose to wait for another container before starting.
I have tried using “depends_on” and health checks but cant seem to get it right.
What i think could achieve my goal in my situation is adding a health check to make sure /media/data is fully accessible or maybe even attaching and detaching before starting contaier1 but unfortunately I have no clue how to set this up properly.
here is an example of my setup, any suggestions are greatly appreciated I look forward to your response.
OS: Ubuntu 22.04 VM
Docker compose Version: 2.20
Portianer Version: 2.18.4
container1: image: container1/contaier1:latest stdin_open: true tty: true volumes: - /home/dlone/Configs/config1/config:/config - /home/dlone/Configs/config1/log:/log # logs will be here on the host - /media/data:/data:shared environment: - TZ=America/Los_Angeles devices: - /dev/fuse:/dev/fuse:rwm cap_add: - SYS_ADMIN security_opt: - apparmor:unconfined - no-new-privileges healthcheck: interval: 10s timeout: 5s retries: 5 container2: depends_on: container1: condition: service_healthy image: container2/container2:latest container_name: container2 network_mode: bridge devices: - /dev/dri:/dev/dri ports: - 32400:32400 environment: - PUID=1000 - PGID=1000 - TZ=America/Los_Angeles volumes: - /home/dlone/Configs/Config2:/config - /media/data/:/media/data healthcheck: interval: 10s timeout: 5s retries: 5 restart: unless-stopped