Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Docker commands in Linux using TUI #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions Functions/docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import os

print("""\t\tWelcome to Docker Tools
\t\t------------------------""")
while True:

print("""Press 1 : Image Commands
Press 2 : Container Commands
press 3 : Make a Container for web server
Press 0 : Exit""")

choice = int(input("Enter your Choice: "))
while True:
if choice == 1:
os.system("clear")
print("""\t Press 1: List available Images
Press 2: Pull New image from the Repo
Press 3: Remove an image
Press 0: Go back to Main Menu""")

choice1 = int(input("Enter your Choice: "))
if choice1 == 1:
os.system("docker images")
elif choice1 == 2:
repoimg = input("Enter the image you want to download: ")
os.system("docker pull {}".format(repoimg))
elif choice1 ==3:
os.system("docker image ls")
rmimg = input("Enter the name of the image you want to remove: ")
os.system("docker image rm {}".format(rmimg))
elif choice1 == 0:
break
else:
print("INVALID OPTION SELECTED")

elif choice ==2:
print("""\t Press 1: List available Containers
Press 2: Make a new Container
Press 3: Remove a Container
Press 0 : Go back to Main Menu """)

choice2 = int(input("Enter your Choice: "))
if choice2 ==1:
os.system("docker ps -a")
elif choice2 ==2:
os.system("docker image ls")
imgname = input("Enter the name of the OS: ")
osname = input("Enter the name for your Container: ")
os.system("docker run -itd --name {} {}".format(osname,imgname))
print("""\t\tPress 1 to go inside the Conatiner
Press 2 to go to previos menu""")
choice2a = int(input("Enter Your Choice : "))
if choice2a == 1:
os.system("docker attach {}".format(osname))
elif choice2a == 0:
break

elif choice2 ==3:
os.system("docker ps -a")
osname = input("Enter the name of the container to remove permanently: ")
os.system("docker container rm -f {}".format(osname))
elif choice2 == 0:
break
else:
print("INVALID OPTION SELECTED")
elif choice == 3:
os.system("docker pull web:v1")
os.system("docker run -itd web:v1")
print("Server started successfully")
input("Press ENTER KEY to continue")
break
elif choice == 0 :
exit()
else:
print("INVALID OPTION SELECTED")
break

input("Press ENTER KEY to Continue")