-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyDockerProject.py
362 lines (335 loc) · 13.8 KB
/
MyDockerProject.py
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
import os
import getpass
os.system("tput setaf 5")
print("---------------------------------------------------")
print("---------------------------------------------------")
os.system("tput setaf 7")
print("HEY ALL , THIS IS MY FIRST DOCKER TUI PROJECT")
os.system("tput setaf 4")
print("....................................................")
os.system("tput setaf 3")
pswrd = detpass.getpass("KINDLY ENTER YOUR PASSWORD : ")
apass = "redhat"
if pswrd!= apass:
print("OOPS!! WRONG PASSWORD , TRY AGAIN")
exit()
os.system("tput setaf 7")
print("What would you like : (local/remote) :" , end=" ")
location = input()
print(location)
if location == "remote" :
remoteIP = input("Your IP please : ")
os.system("tput setaf 3")
os.system("figlet /t/t WELCOME!!! YOU ARE IN DOCKER WORLD")
os.system("tput setaf 8 ")
print("IN ORDER TO PERFORM ANY TASK , PRESS BUTTON 4 : ")
os.system("tput setaf 1")
while True :
print("""
PRESS 1: INSTALL DOCKER COMMUNITY EDITION.
PRESS 2: GEDIT FILE CREATION
PRESS 3: OPEN GEDIT FILE AND THEN GO THROUGH THE REPO LIST
PRESS 4: START THE DOCKER AND FOR OTHER COMMANDS TO RUN
PRESS 5: CHECK DOCKER VERSION
PRESS 6: PULL IMAGES FROM DOCKER
PRESS 7: CREATE NEW CONTAINER IMAGE BY USING IMAGE NAME
PRESS 8: CREATE A NEW CONTAINER IMAGE WITH GIVING ANY NAME OF THE CONTAINER IMAGE i.e(topOs , pop etc.)
PRESS 9: CHECK LIST OF CONTAINER
PRESS 10:INSTALL wget,net-tools AND OTHER SOFTWARE USING yum install COMMAND
PRESS 11:REMOVE ALL CONTAINERS
PRESS 12:INSPECT , WHAT DO YOU WANT BY USNING docker inspect COMMAND
PRESS 13:CHECK FREE SPACE AVAILABLE IN YOUR MEMORY
PRESS 14:ENABLE httpd server INSIDE THE DOCKER
PRESS 15:PUSH YOUR CONTAINER IMAGE INSIDE THE DOCKER HUB
PRESS 16:CHECK netstat -tnlp
PRESS 17:NUMBER OF IMAGES YOU HAVE
PRESS 18:curl TO IP
PRESS 19:INPUT URL USING SSL
PRESS 20:COMMIT THE DOCKER IMAGE AND REPOSITORY FILE
PRESS 21:CHECK THE GATEWAY OF YOUR CONTAINER
PRESS 22:INSIDE THE DOCKER CREATE A NER CONTAINER
PRESS 23:CHECK VOLUME LIST
PRESS 24:START THE docker-compose file
PRESS 25:EXIT
""")
print("Press any press button to perform the task you want : " , end="")
ch = input()
print(ch)
if location == "local":
if int(ch) == 1:
os.system("tput setaf 7 ")
os.system("yum install docker-ce --nobest")
elif int(ch) == 2:
print("Give file name :" , end = '')
file_name = input()
os.system("tput setaf 7")
os.system("gedit {}".format(create_name))
elif int(ch) == 3:
os.system("tput setaf 7")
os.system("gedit docker.repo")
elif int(ch) == 4:
print("Enter what you want to do start/stop/restart :" , end=" ")
create_name = input()
os.system("systemctl start {}" .format(create_name))
elif int(ch) == 5:
print("enter what do you want to check :" , end=' ')
check_name = input(ch)
os.system("tput setaf 6")
os.system("docker {} " .format(check_name))
elif int(ch) == 6:
print("enter image name to pull :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker pull {} " .format(image__name))
elif int(ch) == 7:
print("image name to create container :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker run -it {} " .format(image__name))
elif int(ch) == 8:
print("give name to the container:" , end = ' ')
name = input()
os.system("docker container run -it --name {}" .format(name))
print("enter the image name to create container :" , end = ' ')
image_name = input()
os.system("docker run -it {}" .format(image_name))
print("press 0 to exit")
os.system("exit")
elif int(ch) == 9:
print("enter what you want to install :" , end = ' ')
install_name = input()
os.system("tput setaf 6")
os.system("yum install {}" .format("install_name"))
elif int(ch) == 10:
if int(ch) == 1:
os.system("tput setaf 7 ")
os.system("yum install docker-ce --nobest")
elif int(ch) == 2:
print("Give file name :" , end = '')
file_name = input()
os.system("tput setaf 7")
os.system("gedit {}".format(create_name))
elif int(ch) == 3:
os.system("tput setaf 7")
os.system("gedit docker.repo")
elif int(ch) == 4:
print("Enter what you want to do start/stop/restart :" , end=" ")
create_name = input()
os.system("systemctl start {}" .format(create_name))
elif int(ch) == 5:
print("enter what do you want to check :" , end=' ')
check_name = input(ch)
os.system("tput setaf 6")
os.system("docker {} " .format(check_name))
elif int(ch) == 6:
print("enter image name to pull :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker pull {} " .format(image__name))
elif int(ch) == 7:
print("image name to create container :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker run -it {} " .format(image__name))
elif int(ch) == 8:
print("give name to the container:" , end = ' ')
name = input()
os.system("docker container run -it --name {}" .format(name))
os.system("tput setaf 5")
os.system("docker rm -f $(docker os -a -q)")
elif int(ch) == 11:
print("what do you want to inspect :" ,end = ' ')
inspect_name = input()
os.system("tput setaf 5")
os.system("docker inspect {} " .format(inspect_name))
elif int(ch) == 12:
os.system("tput setaf 6")
os.system("free -m")
elif int(ch) == 13:
os.system("tput setaf 5")
os.system("cd /var/run/httpd/")
elif int(ch) == 14:
print("enter user id and image name")
enter_name = input()
os.system("tput setaf 5")
os.system("docker push {}" .format(enter_name))
elif int(ch) == 15:
os.system("tput setaf 5")
os.system("netstat -tnlp")
elif int(ch) == 16:
os.system("tput setaf 5")
os.system("docker rm -f $(docker os -a -q)")
elif int(ch) == 17:
print("enter image name :" , end = ' ')
image_name = input()
os.system("tput setaf 5")
os.system("docker images | grep {}" .format(image_name))
elif int(ch) == 18:
print("enter IP :" , end =' ')
ip_no = input()
os.system("tput setaf 5")
os.system("curl {}" .format(URL_name))
elif int(ch) == 19:
print("Enter URL :" ,end = ' ')
URL_name = input()
os.system("tput setaf 5")
os.system("curl -sSL {}" .format(URL_name))
elif int(ch) == 20:
print("enter the image name to commit :" , end = ' ')
Image_name = input()
os.system("docker commit {}" .format(Image_name))
print("Enter repository file name to commit :" , end = ' ')
file_name = input()
os.system("tput setaf 5")
os.system("docker commit {}" .format(file_name))
elif int(ch) == 21:
os.system("tput setaf 5")
os.system("route -n")
elif int(ch) == 17:
print("enter image name :" , end = ' ')
image_name = input()
os.system("tput setaf 5")
os.system("docker images | grep {}" .format(image_name))
elif int(ch) == 18:
print("enter IP :" , end =' ')
ip_no = input()
os.system("tput setaf 5")
os.system("curl {}" .format(URL_name))
elif int(ch) == 19:
print("Enter URL :" ,end = ' ')
URL_name = input()
os.system("tput setaf 5")
os.system("curl -sSL {}" .format(URL_name))
elif int(ch) == 20:
print("enter the image name to commit :" , end = ' ')
Image_name = input()
os.system("docker commit {}" .format(Image_name))
print("Enter repository file name to commit :" , end = ' ')
file_name = input()
os.system("tput setaf 5")
os.system("docker commit {}" .format(file_name))
elif int(ch) == 21:
os.system("tput setaf 5")
os.system("route -n")
elif int(ch) == 22:
print("enter volume name :" end = ' ')
volume_name = input()
os.system("tput setaf 5")
os.system("docker volume create {}" .format(volume_name))
elif int(ch) == 23:
os.system("tput setaf 5")
os.system("docker volume ls")
elif int(ch) == 24:
os.system("tput setaf 4")
os.system("docker-compose up")
elif int(ch) == 25:
os.system("tput setaf 2")
os.system("exit")
os.system("figlet -f block \t\t THANKS A LOT !")
else :
print("OPTION NOT SUPPORTED")
input("Enter to continue >>>>>>>>>>")
os.system("clear")
elif locatio == "remote" :
os.system("tput setaf 3")
if int(ch) == 1:
os.system("tput setaf 7 ")
os.system("yum install docker-ce --nobest")
elif int(ch) == 2:
print("Give file name :" , end = '')
file_name = input()
os.system("tput setaf 7")
os.system("gedit {}".format(create_name))
elif int(ch) == 3:
os.system("tput setaf 7")
os.system("gedit docker.repo")
elif int(ch) == 4:
print("Enter what you want to do start/stop/restart :" , end=" ")
create_name = input()
os.system("systemctl start {}" .format(create_name))
elif int(ch) == 5:
print("enter what do you want to check :" , end=' ')
check_name = input(ch)
os.system("tput setaf 6")
os.system("docker {} " .format(check_name))
elif int(ch) == 6:
print("enter image name to pull :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker pull {} " .format(image__name))
elif int(ch) == 7:
print("image name to create container :" , end= ' ')
image__name = input(ch)
os.system("tput setaf 6")
os.system("docker run -it {} " .format(image__name))
elif int(ch) == 8:
print("give name to the container:" , end = ' ')
name = input()
os.system("docker container run -it --name {}" .format(name))
elif int(ch) == 11:
print("what do you want to inspect :" ,end = ' ')
inspect_name = input()
os.system("tput setaf 5")
os.system("docker inspect {} " .format(inspect_name))
elif int(ch) == 12:
os.system("tput setaf 6")
os.system("free -m")
elif int(ch) == 13:
os.system("tput setaf 5")
os.system("cd /var/run/httpd/")
elif int(ch) == 14:
print("enter user id and image name")
enter_name = input()
os.system("tput setaf 5")
os.system("docker push {}" .format(enter_name))
elif int(ch) == 15:
os.system("tput setaf 5")
os.system("netstat -tnlp")
elif int(ch) == 16:
os.system("tput setaf 5")
os.system("docker rm -f $(docker os -a -q)")
elif int(ch) == 17:
print("enter image name :" , end = ' ')
image_name = input()
os.system("tput setaf 5")
os.system("docker images | grep {}" .format(image_name))
elif int(ch) == 18:
print("enter IP :" , end =' ')
ip_no = input()
os.system("tput setaf 5")
os.system("curl {}" .format(URL_name))
elif int(ch) == 19:
print("Enter URL :" ,end = ' ')
URL_name = input()
os.system("tput setaf 5")
os.system("curl -sSL {}" .format(URL_name))
elif int(ch) == 20:
print("enter the image name to commit :" , end = ' ')
Image_name = input()
os.system("docker commit {}" .format(Image_name))
print("Enter repository file name to commit :" , end = ' ')
file_name = input()
os.system("tput setaf 5")
os.system("docker commit {}" .format(file_name))
elif int(ch) == 21:
os.system("tput setaf 5")
os.system("route -n")
elif int(ch) == 22:
print("enter volume name :" end = ' ')
volume_name = input()
os.system("tput setaf 5")
os.system("docker volume create {}" .format(volume_name))
elif int(ch) == 23:
os.system("tput setaf 5")
os.system("docker volume ls")
elif int(ch) == 24:
os.system("tput setaf 4")
os.system("docker-compose up")
elif int(ch) == 25:
os.system("tput setaf 2")
os.system("exit")
os.system("figlet -f block \t\t THANKS A LOT !")
else :
print("OPTION NOT SUPPORTED")
input("Enter to continue >>>>>>>>>>")
os.system("clear")