ericreager Posted September 27, 2023 Share Posted September 27, 2023 Hi All - I'm working on a script that involves stopping and then starting all docker containers. I have it working, but the containers start in some default order and not the top-down order I have them set in the Docker tab. Is there a way to have them start according to the order and delay settings in the Docker tab? Or does the script just need to start them individually in the desired order? Thanks in advance, Eric Quote Link to comment
ericreager Posted September 28, 2023 Author Share Posted September 28, 2023 Figured it out partially on my own. The order set on the Docker tab seems to be stored in /boot/config/plugins/dockerMan/userprefs.cfg, each line having a container name in quotes. The script below goes through the config line by line and does a docker start on whatever is contained within the quotes, with a 30 second wait between each container. Ideally it should only wait the amount of time set for each container on the Docker tab, but I haven't found where those values are stored yet. #!/bin/bash # Specify the path to your .cfg file CFG_FILE="/boot/config/plugins/dockerMan/userprefs.cfg" # Check if the file exists if [ ! -f "$CFG_FILE" ]; then echo "Error: Config file not found." exit 1 fi # Read the .cfg file line by line and start Docker containers while IFS= read -r line do # Extract container name within quotes container_name=$(echo "$line" | sed -n 's/.*"\(.*\)".*/\1/p') # Start Docker container docker start "$container_name" # Check the exit status if [ $? -eq 0 ]; then echo "Container '$container_name' started successfully. Waiting to start next Container." sleep 30 # Wait for 30 seconds before starting the next container else echo "Error: Failed to start container '$container_name'." fi done < "$CFG_FILE" echo "All containers started." Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.