-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontainer
More file actions
executable file
·135 lines (106 loc) · 2.82 KB
/
container
File metadata and controls
executable file
·135 lines (106 loc) · 2.82 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# Name of image & container.
image_name='forthecity-wordpress'
container_name='forthecity-wordpress'
external_port='6159'
internal_port='80'
# Build docker image based on Dockerfile, if creating or starting container.
if [ "$1" = "-c" ] || [ "$1" = "-s" ] || [ "$1" = "-r" ] || [ "$1" = "-t" ]; then
echo "Building $image_name image..."
docker build -t "$image_name" .
fi
# -h
# Print help.
if [ "$1" = "-h" ]; then
help_output= cat <<HelpText
APP DOCKER MANAGER
This script manages Docker for this application. It may need to be run as
the root user on your system. The create, test, start & restart flags attempt
to build or rebuild the image based on the Dockerfile before executing.
ARGUMENTS
-h
Prints help text.
-c
Creates & starts a container based on '$container_name' image.
-s
Starts the container named '$container_name'.
-r
Restarts the container named '$container_name'.
-i
Inspects the container named '$container_name'.
-l
Displays the log of the container.
-t
Runs the test suite for the application.
--interactive
Runs an interactive container.
--status
Shows status of the container.
--stop
Stops a container named '$container_name'.
--delete
Deletes a container named '$container_name'.
HelpText
echo $help_output
fi
# -c
# Creates & runs the container.
if [ "$1" = "-c" ]; then
docker run -d -e MYSQL_ROOT_PASSWORD="default" --name="wordpress-mysql" mysql
sleep 3
echo "Creating & starting $container_name container..."
docker run -d -e WP_DEBUG=true -v $PWD:/var/www/html/wp-content/plugins/restore-strategies \
-p $external_port:$internal_port --name="$container_name" \
--link wordpress-mysql:mysql $image_name
fi
# -s
# Starts the container.
if [ "$1" = "-s" ]; then
docker start wordpress-mysql
sleep 3
echo "Starting $container_name container..."
docker start $container_name
fi
# -r
# Restart the container.
if [ "$1" = "-r" ]; then
echo "Restarting $container_name container..."
docker restart --time=0 $container_name
fi
# -i
# Inspects container.
if [ "$1" = "-i" ]; then
docker inspect $container_name
fi
# -l
# Show logs.
if [ "$1" = "-l" ]; then
docker logs -f -t $container_name
fi
# -t
# Run tests.
#if [ "$1" = "-t" ]; then
#fi
# --interactive
# Run interactive container
if [ "$1" = "--interactive" ]; then
docker run --rm -i -t -v $PWD:/var/www/html/wp-content/plugins/restore-strategies \
--link wordpress-mysql:mysql $image_name /bin/bash
fi
# --status
# Shows status.
if [ "$1" = "--status" ]; then
docker ps -a --filter "name=$container_name"
fi
# --stop
# Stop the container.
if [ "$1" = "--stop" ]; then
echo "Stopping $container_name container..."
docker stop --time=0 $container_name
fi
# --delete
# Deletes container.
if [ "$1" = "--delete" ]; then
echo "Deleting $container_name container..."
docker rm $container_name
fi