-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab
executable file
·48 lines (38 loc) · 1.13 KB
/
lab
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
#! /bin/bash
DOCKER_COMPOSE_FILE="$CHIPS_LAB_HOME/docker-compose.yml"
DOCKER_COMPOSE_PROJECT_NAME="chips-lab"
CMD_LIST="list"
CMD_START="start"
CMD_STOP="stop"
CMD_RESTART="restart"
CMD_LOGS="logs"
CMD_SH="sh"
CMD_DOWN="down"
CMD_UP="up"
CMD=$1
CONTAINER=$2
if [[ $CMD == $CMD_LIST ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE -p $DOCKER_COMPOSE_PROJECT_NAME ps --format json | jq -r '[.Service, .Name, .Status] | @tsv'
fi
if [[ $CMD == $CMD_START ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE start $CONTAINER
fi
if [[ $CMD == $CMD_STOP ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE stop $CONTAINER
fi
if [[ $CMD == $CMD_RESTART ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE stop $CONTAINER
docker-compose -f $DOCKER_COMPOSE_FILE start $CONTAINER
fi
if [[ $CMD == $CMD_LOGS ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE logs $CONTAINER -f
fi
if [[ $CMD == $CMD_SH ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE exec -it $CONTAINER sh
fi
if [[ $CMD == $CMD_DOWN ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE down $CONTAINER
fi
if [[ $CMD == $CMD_UP ]]; then
docker-compose -f $DOCKER_COMPOSE_FILE up $CONTAINER -d
fi