Skip to content

Instantly share code, notes, and snippets.

@brunobolting
Last active July 27, 2020 13:59
Show Gist options
  • Save brunobolting/e373b03d50b57d73d7d87f4523260b80 to your computer and use it in GitHub Desktop.
Save brunobolting/e373b03d50b57d73d7d87f4523260b80 to your computer and use it in GitHub Desktop.
[V2] Script Shell to create shortcuts for docker-compose, create an alias (I'm recommend 'dc') on .bashrc to this file
#!/bin/bash
# Variables
COMMAND=$1
PARAMS=($@)
unset PARAMS[0]
# Functions
docker_up() {
docker-compose up "$@"
}
docker_stop() {
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker network prune -f
}
# Main
case $COMMAND in
up)
docker_up "${PARAMS[@]}" ;;
stop | down)
docker_stop ;;
restart | r)
docker_stop
docker_up "${PARAMS[@]}" ;;
*)
echo 'Empty or Unknown command, try: up, stop or restart' ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment