Last active
July 27, 2020 13:59
-
-
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
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
#!/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