forked from akkadotnet/Akka.Persistence.PostgreSql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_db_container.sh
33 lines (32 loc) · 869 Bytes
/
start_db_container.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
while getopts ":i:" opt; do
case $opt in
i)
imageName=$OPTARG
echo "imageName = $imageName"
echo "Tearing down any existing containers with deployer=akkadotnet"
runningContainers=$(docker ps -aq -f label=deployer=akkadotnet)
if [ ${#runningContainers[@]} -gt 0 ]
then
for i in $runningContainers
do
if [ "$i" != "" ] # 1st query can return non-empty array with null element
then
docker stop $i
docker rm $i
fi
done
fi
echo "Starting docker container with imageName=$imageName and name=akka-postgres-db"
docker run -d --name=akka-postgres-db -p 5432:5432 -l deployer=akkadotnet -e POSTGRES_PASSWORD=postgres $imageName
;;
:)
echo "imageName (-i) argument required" >&2
exit 1
;;
\?)
echo "imageName (-i) flag is required" >&2
exit 1
;;
esac
done