-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-networking.sh
46 lines (31 loc) · 1009 Bytes
/
docker-networking.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
34
35
36
37
38
39
40
41
42
43
44
45
46
# script to instantiate docker network
# usage: bash docker-networking.sh
# remove network if already present
docker network rm application-network
# create network
docker network create application-network
# TESTING LINK - PING #
# run database image and connect to network
cd database
bash run-container.sh
# run elasticsearch image and connect to network
cd ../elasticsearch
bash run-container.sh
# run server image and connect to network
cd ../server
bash run-container.sh
# exec into server container and ping database
docker exec -it server ping -c 1 db
echo "SUCCESS - containers linked. Tested via ping."
# TESTING LINK - CURL ELASTICSEARCH #
echo "Time delay to allow for container linking..."
sleep 10 # required delay until networking is properly setup
docker exec -it server curl es:9200
echo "SUCCESS - containers linked. Tested via curl."
# stop and remove server and database containers
docker stop server
docker rm server
docker stop db
docker rm db
docker stop es
docker rm es