-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·52 lines (42 loc) · 1.69 KB
/
run
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
#!/bin/bash
echo "########### CURRENT IMAGES ################"
docker images | grep latest
echo "###########################################"
echo ""
read -p "Image name to use: " image
read -p "Location of application files: " application
read -p "Port to use for web server: (8000) " port
port=${port:-8000}
read -p "Name for the container: (Random) " name
name=${name:-$RANDOM}
echo "########### CURRENT VOLUMES ###############"
docker ps -a | grep busybox
echo "###########################################"
echo ""
read -p "Volume with MySQL Data: " volumesfrom
read -p "Do you want to expose MySQL? (Y/n) " exposeMySQL
iam=whoami
LOGS=~/logs/docker/$name
# Create the logs directory always in home
mkdir -p $LOGS
if [[ $exposeMySQL == "Y" || $exposeMySQL == "y" || $exposeMySQL = "" ]]; then
read -p "Port to expose MySQL: (Random) " mysqlport
mysqlport=${mysqlport:-$RANDOM}
echo ""
echo "Starting the container, this can take a few seconds, please wait..."
echo ""
docker run -d -p $port:80 -p $mysqlport:3306 --volumes-from=$volumesfrom -v $application:/var/www -v $LOGS:/var/log/supervisor --name $name $image
else
echo ""
echo "Starting the container, this can take a few seconds, please wait..."
echo ""
docker run -d -p $port:80 --volumes-from=$volumesfrom -v $application:/var/www -v ~/logs/docker/$name:/var/log/supervisor --name $name $image
fi
echo "Running $image"
echo "Container name: $name"
if [[ $exposeMySQL == "Y" || $exposeMySQL == "y" || $exposeMySQL = "" ]]; then
echo "MySQL Port: $mysqlport"
fi
echo "List supervisor logs with ls $LOGS"
echo "To see the MySQL information, wait a few seconds and then do docker logs $name"
echo "Done. Access the server on http://localhost:$port"