Last active
May 22, 2019 11:30
-
-
Save lcwyo/70e1035d68ed152e238ea1a66fd5aea4 to your computer and use it in GitHub Desktop.
bash script to restart & rebuild docker containers running in docker compose. probably not best practice :-|
This file contains hidden or 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 | |
| # restart services in docker-compose | |
| service-restart() { | |
| docker-compose stop $@ | |
| docker-compose rm -f -v $@ | |
| docker-compose up --force-recreate --no-start $@ | |
| docker-compose start $@ | |
| } | |
| if [ $# -eq 0 ]; then | |
| echo "" | |
| echo "you must include the name of a docker-compose service" | |
| echo "you must be in a directory where a suitable configuration file in this directory or any parent." | |
| echo "Supported filenames: docker-compose.yml, docker-compose.yaml" | |
| echo "" | |
| exit 1 | |
| fi | |
| for f in $PWD/docker-compose.y*; do | |
| if [ -e "$f" ]; then | |
| # echo "supported files found" | |
| service-restart $@ | |
| else | |
| echo "you must be in a directory where a suitable configuration file in this directory or any parent." | |
| exit 1 | |
| fi | |
| break | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment