Add command to restart all docker containers
This commit is contained in:
		
							
								
								
									
										29
									
								
								.bin/docker-restart-all-containers
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										29
									
								
								.bin/docker-restart-all-containers
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
|  | ||||
| readonly = DOCKER_FOLDER="/srv/" | ||||
|  | ||||
| function ok() | ||||
| { | ||||
|     echo -e "\e[32mdone\e[0m" | ||||
| } | ||||
|  | ||||
| function failed() | ||||
| { | ||||
|     echo -e "\e[31mfailed\e[0m" | ||||
| } | ||||
|  | ||||
| function main() { | ||||
|  | ||||
|     container_list=$(find "${DOCKER_FOLDER}" -mindepth 1 -maxdepth 1 -type d ! -iname "archives" ! -iname "images" ! -iname "lost+found") | ||||
|  | ||||
|     for container_path in ${container_list}; do | ||||
|         cd "${container_path}" | ||||
|         docker compose down \ | ||||
|         && docker compose stop \ | ||||
|         && docker compose up -d | ||||
|         cd - &>/dev/null | ||||
|     done | ||||
| } | ||||
|  | ||||
| main | ||||
| @@ -0,0 +1,3 @@ | ||||
| function docker-restart-all-containers | ||||
| 	bash "$HOME/.bin/docker-restart-all-containers" | ||||
| end | ||||
		Reference in New Issue
	
	Block a user