I have written this bash script to autostart the containers:
#!/bin/bash
# Name of the container to check
CONTAINER_NAME="nextcloud-aio-mastercontainer"
sleep 120 # Wait 180 seconds before start checking
# Function to check if the container is running and healthy
is_container_healthy() {
local STATUS=$(docker inspect --format '{{.State.Health.Status}}' $CONTAINER_NAME 2>/dev/null)
[[ "$STATUS" == "healthy" ]]
}
# Wait until the container is healthy
echo "Waiting for the container $CONTAINER_NAME to be healthy..."
until is_container_healthy; do
echo "The container $CONTAINER_NAME is not healthy yet. Waiting..."
sleep 10 # Wait 10 seconds before checking again
done
# Once the container is healthy, wait an additional 30 seconds
echo "The container $CONTAINER_NAME is healthy. Waiting an additional 30 seconds..."
sleep 30
# Run the desired command
echo "Running the command..."
docker exec -it $CONTAINER_NAME sudo -u www-data php /var/www/docker-aio/php/src/Cron/StartAndUpdateContainers.php
echo "Command execution completed."
So there is already a way in the mastercontainer to simply start/start and update/stop the child containers, so why cant this be an an official way?