I am running python within a container.
The goal is to exit out of the container from within the running python code after receiving the input
value quit. I tried the below code:
import subprocess
def qq():
while True:
choice = ""
choice = input("Type \"quit\" to exit container> ")
if choice == 'quit':
print("Exiting container")
subprocess.call("exit", shell=True)
break
else:
print("Invalid input.")
qq()
After I docker exec and bash into the container, and run the above code, following is the output:
root@container:/pyScript#
root@container:/pyScript# python3 kwit.py
Type "quit" to exit container>
Invalid input.
Type "quit" to exit container> quit
Exiting container
root@container:/pyScript#
root@container:/pyScript#
Right now, the input quit takes me back to the container shell.
I would like the quit input to exit out of the my python's prompt and take me straight back to the docker host (instead of the container)