Skip to content

Commit 109792c

Browse files
committed
Make docker-compose flexible
1 parent f2813b3 commit 109792c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

services

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
#
33
# Command Line Interface to start all services associated with the Getting-Started Tutorial
44
#
5-
# For this tutorial the commands are merely a convenience script to run docker-compose
6-
#
5+
# For this tutorial the commands are merely a convenience script to run ${dockerCmd}#
76

87
set -e
98

10-
if (( $# != 1 )); then
11-
echo "Illegal number of parameters"
9+
dockerCmd="docker compose"
10+
if (( $# == 2 )); then
11+
dockerCmd="docker-compose"
12+
fi
13+
14+
if (( $# < 1 )); then echo "Illegal number of parameters"
1215
echo "usage: services [create|start|stop]"
1316
exit 1
1417
fi
1518

1619

1720
stoppingContainers () {
1821
echo "Stopping running containers"
19-
docker-compose down -v --remove-orphans
22+
${dockerCmd} down -v --remove-orphans
2023
}
2124

2225
displayServices () {
@@ -36,7 +39,7 @@ case "${command}" in
3639
stoppingContainers
3740
echo -e "Starting containers: including \033[1;35mFogFlow\033[0m, an \033[1mNGINX\033[0m instance, and \033[1mRabbitMQ\033[0m message broker."
3841
echo ""
39-
docker-compose up -d --remove-orphans
42+
${dockerCmd} up -d --remove-orphans
4043
displayServices
4144
;;
4245
"stop")
@@ -47,7 +50,7 @@ case "${command}" in
4750
export $(cat .env | grep "#" -v)
4851
echo "Pulling Docker images"
4952
docker pull curlimages/curl
50-
docker-compose pull
53+
${dockerCmd} pull
5154
;;
5255
*)
5356
echo "Command not Found."

0 commit comments

Comments
 (0)