2024-10-28 15:03:39 +01:00
|
|
|
# Search for docker-compose files in the current and all sub direcotries and run docker compose with provided arguments
|
|
|
|
|
2024-10-28 12:31:50 +01:00
|
|
|
function dc() {
|
2024-10-29 13:59:15 +01:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
# display usage if no parameters given
|
|
|
|
echo "Search for docker-compose files in the current and all sub direcotries and run docker compose with provided arguments"
|
|
|
|
echo "Usage: dc <docker compose commands>"
|
|
|
|
return 1
|
|
|
|
else
|
2024-10-28 15:03:39 +01:00
|
|
|
# Save current working directory
|
|
|
|
CURRENT_DIR="${PWD}"
|
2024-10-29 13:59:15 +01:00
|
|
|
|
2024-10-28 22:27:06 +01:00
|
|
|
for file in $(find ${PWD} -maxdepth 2 -type f -regextype posix-extended -regex '.*(docker-compose|compose)\.ya?ml' | sort); do
|
2024-10-29 13:59:15 +01:00
|
|
|
cd $(dirname "$file")
|
|
|
|
docker compose $@
|
2024-10-28 15:03:39 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# Change back to saved working directory
|
|
|
|
cd ${CURRENT_DIR}
|
2024-10-29 13:59:15 +01:00
|
|
|
fi
|
|
|
|
}
|