-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.sh
executable file
·63 lines (60 loc) · 2.02 KB
/
docker.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Note: container host address: docker.for.mac.localhost
DOCKER=docker
IMG_NAME=mfatihaktas/edge-load-balance # :latest
CONT_NAME=edge-service
NET_NAME=edge-net
if [ $1 = 'b' ]; then
rm *.png *.log
$DOCKER build -t $IMG_NAME .
elif [ $1 = 'rn' ]; then
$DOCKER run --name nginx -d -p 8080:80 nginx
elif [ $1 = 'ri' ]; then
$DOCKER run --name $CONT_NAME -it --rm --net bridge $IMG_NAME /bin/bash
elif [ $1 = 'rmd' ]; then
[ -z "$2" ] && { echo "Which master [0, *] ?"; exit 1; }
# $DOCKER run --name $CONT_NAME -it --rm $IMG_NAME ping localhost # Test that should work
$DOCKER run --name $CONT_NAME -d -it --rm $IMG_NAME python3 -u /home/app/master.py --i=$2
elif [ $1 = 'rmi' ]; then
[ -z "$2" ] && { echo "Which master [0, *] ?"; exit 1; }
# --net $NET_NAME --ip 192.168.1.0
# -p 5000:5000/tcp -p 5000:5000/udp \
$DOCKER run --name edge-master -it --rm \
--net bridge \
$IMG_NAME python3 -u /home/app/master.py --i=$2 --wip_l='null'
elif [ $1 = 'rc' ]; then
[ -z "$2" ] && { echo "Which client [0, *] ?"; exit 1; }
# -p 5000:5000/tcp -p 5000:5000/udp \
$DOCKER run --name edge-client -it --rm \
--net bridge \
$IMG_NAME python3 -u /home/app/client.py --i=$2 --mid_ip_m='{"m0": "10.0.1.0"}' #'{"m0": "172.17.0.2"}'
elif [ $1 = 'stop' ]; then
$DOCKER stop $CONT_NAME
elif [ $1 = 'kill' ]; then
$DOCKER kill $CONT_NAME
elif [ $1 = 'bash' ]; then
# $DOCKER exec -it $CONT_NAME bash
$DOCKER exec -it $2 bash
elif [ $1 = 'lsc' ]; then
$DOCKER ps --all
elif [ $1 = 'lsi' ]; then
$DOCKER images
elif [ $1 = 'tag' ]; then
$DOCKER tag $IMG_NAME $HUB_IMG_NAME
elif [ $1 = 'rm' ]; then
$DOCKER rm $2
elif [ $1 = 'rmi' ]; then
$DOCKER image rm $2
elif [ $1 = 'push' ]; then
$DOCKER push $IMG_NAME
elif [ $1 = 'pull' ]; then
$DOCKER pull $IMG_NAME
elif [ $1 = 'cn' ]; then
$DOCKER network create --subnet=192.168.0.0/16 $NET_NAME
elif [ $1 = 'rn' ]; then
$DOCKER network rm $NET_NAME
elif [ $1 = 'lsn' ]; then
$DOCKER network ls
else
echo "Arg did not match!"
fi