Created
April 13, 2021 17:43
-
-
Save rietta/0fe8db5b3d495be6ce37d3415e20852a to your computer and use it in GitHub Desktop.
Shell script (Ruby language) to stop all docker-compose projects in any folder on the system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Find all the directories with a docker-compose.yml file and stop the services. | |
# | |
# Place this file in your path, such as ~/bin/fullstop and chmod 755. | |
DOCKER_COMPOSE_COMMAND = 'docker-compose'.freeze | |
files = `locate docker-compose.yml`.split | |
files.each do |docker_compose_file| | |
next unless File.basename(docker_compose_file) == 'docker-compose.yml' | |
parent_directory = File.dirname(docker_compose_file) | |
puts "Stopping program in #{parent_directory}" | |
Dir.chdir(parent_directory) do | |
system("#{DOCKER_COMPOSE_COMMAND} stop") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment