Skip to content

Instantly share code, notes, and snippets.

@softwaredoug
Created May 19, 2023 12:45
Show Gist options
  • Save softwaredoug/8bd8e3fcce98887ad6c2f5fe6c977f8e to your computer and use it in GitHub Desktop.
Save softwaredoug/8bd8e3fcce98887ad6c2f5fe6c977f8e to your computer and use it in GitHub Desktop.
Put as 'docker-compose' and it will protect you from inadvertent `docker-compose down`
#!/bin/bash
args=($@)
for i in "${!args[@]}"; do
arg=${args[$i]}
if [[ "$arg" = "down" ]];then
echo "Stopping instead of downing"
echo "Use 'docker-compose destroy' to destroy"
args[i]="stop"
echo "Running docker-compose ${args[@]}"
elif [[ "$arg" = "destroy" ]];then
args[i]="down"
echo "Running docker-compose ${args[@]}"
fi
done
/usr/local/bin/docker-compose ${args[@]} # Adapt to actual path to docker-compose binary if different
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment