-
Notifications
You must be signed in to change notification settings - Fork 47
/
podman_pause_unpause.sh
executable file
·191 lines (150 loc) · 4.33 KB
/
podman_pause_unpause.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env sh
# podman_pause_unpause.sh demo script.
# This script will demonstrate at an introductory level
# the use of the podman pause and unpause commands.
# Podman must be installed prior to running this script.
# Setting up some colors for helping read the demo output.
# Comment out any of the below to turn off that color.
bold=$(tput bold)
cyan=$(tput setaf 6)
reset=$(tput sgr0)
read_color() {
read -p "${bold}$1${reset}"
}
echo_color() {
echo "${cyan}$1${reset}"
}
setup() {
command -v podman >/dev/null
if [ $? != 0 ]; then
echo $0 requires the podman package to be installed
exit 1
fi
clear
}
intro() {
echo_color "\`podman pause\` Demo"
echo
echo_color "Available at https://github.com/containers/Demos/podman_cli/podman_pause.sh"
echo
}
version() {
echo_color "First check the Podman version"
echo
read_color "podman version"
echo
podman version
echo
echo
read -p "Enter to continue"
clear
}
podman_pull_images() {
echo_color "Let's pull the alpine image"
echo
read_color "podman pull alpine"
podman pull alpine
echo
echo_color "Let's pull the busybox image"
echo
read_color "podman pull busybox"
podman pull busybox
echo
echo_color "Let's look at the images"
echo
read_color "podman images"
podman images
echo
read -p "Enter to continue"
clear
}
podman_do_pause_demo() {
echo_color "Let's create and run an alpine container for 10 minutes."
echo
read_color "podman run --detach --name alpinectr alpine sh -c 'while true ;do sleep 600 ; done'"
podman run --detach --name alpinectr alpine sh -c 'while true ;do sleep 600 ; done'
echo
echo_color "Let's create and run a busybox container for 10 minutes."
echo
read_color "podman run --detach --name busyboxctr busybox sh -c 'while true ;do sleep 600 ; done'"
podman run --detach --name busyboxctr busybox sh -c 'while true ;do sleep 600 ; done'
echo
echo_color "Let's look at the containers"
echo
read_color "podman ps --all"
podman ps --all
echo
echo_color "Let's pause the busyboxctr. This will cause runc to suspend all of the"
echo_color "processes associated with the container."
echo
read_color "podman pause busyboxctr"
podman pause busyboxctr
echo
echo_color "Let's look at the containers, busyboxctr should show 'Paused' now."
echo
read_color "podman ps --all"
podman ps --all
echo
echo_color "Let's pause the alpinectr. This will cause runc to suspend all of the"
echo_color "processes associated with the container."
echo
read_color "podman pause alpinectr"
podman pause alpinectr
echo
echo_color "Let's look at the containers, busyboxctr and alpinectr should both "
echo_color "show 'Paused' now."
echo
read_color "podman ps --all"
podman ps --all
}
podman_do_unpause_demo() {
echo
echo_color "Now let's use the 'podman unpause' command to unpause the containers."
echo
read_color "podman unpause --help"
podman unpause --help
echo
echo_color "Let's unpause the busyboxctr. This will cause runc to unsuspend all of the"
echo_color "processes associated with the container."
echo
read_color "podman unpause busyboxctr"
podman unpause busyboxctr
echo
echo_color "Let's look at the containers, busyboxctr should show 'Up' now."
echo
read_color "podman ps --all"
podman ps --all
echo
echo_color "Let's unpause the alpinectr. This will cause runc to unsuspend all of the"
echo_color "processes associated with the container."
echo
read_color "podman unpause alpinectr"
podman unpause alpinectr
echo
echo_color "Let's look at the containers, busyboxctr and alpinectr should both "
echo_color "show 'Up' now."
echo
read_color "podman ps --all"
podman ps --all
}
clean_images_and_containers() {
echo
echo_color "Time to clean up!"
read_color "podman rm --all --force"
podman rm --all --force
echo
read_color "podman rmi --all --force"
podman rmi --all --force
echo
read -p "Enter to continue"
}
setup
intro
version
podman_pull_images
podman_do_pause_demo
podman_do_unpause_demo
clean_images_and_containers
read -p "End of Demo!!!"
echo
echo "Thank you!"