-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcontainermanage.py
48 lines (38 loc) · 1.34 KB
/
mcontainermanage.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
#!/usr/bin/python2
import commands
import cgi
print "Content-Type: text/html"
print
print "<center>"
print "<h1>Manage The Containers</h1>"
print "<br/><hr/><br/>"
print"""
<script>
function lw(mycname)
{
document.location='mdocker_remove.py?x='+mycname;
}
function lw2(mycname2)
{
document.location='mdocker_stop.py?y='+mycname2;
}
function lw3(mycname3)
{
document.location='cookiemdocker-shell.py?z='+mycname3;
}
</script>
"""
print "<table border='5'>"
print "<tr><th>Image Name</th><th>Container Name</th><th>Status</th><th>IP Address</th><th>Stop</th><th>Shell</th><th>Remove</th></tr>"
z=1
for i in commands.getoutput("sudo docker ps ").split('\n'):
if z == 1:
z+=1
pass
else:
j=i.split()
cStatus=commands.getoutput("sudo docker inspect {0} | jq '.[].State.Status'".format(j[-1]))
ipstatus=commands.getstatusoutput("sudo docker inspect {0} | jq '.[].NetworkSettings.Networks.bridge.IPAddress'".format(j[-1]))
print "<tr><td> " + j[1] + "' </td><td> " + j[-1] + " </td><td>" + cStatus + "</td><td>" + ipstatus[1].strip('"') + "</td><td> <input value='" +j[-1]+"' type='button' onclick=lw2(this.value) /> </td><td> <input value='" +j[-1]+"' type='button' onclick=lw3(this.value) /> </td><td> <input value='" + j[-1] + "' type='button' onclick=lw(this.value) /> </td></tr>"
print "</table>"
print "</center>"