def interact ( self , container : Container ) -> None : cmd = "/bin/bash -c 'source /.environment && /bin/bash'" cmd = "docker exec -it {} {}" . format ( container . id , cmd ) subprocess . call ( cmd , shell = True )
running shell command from a container in python
Connects to the PTY ( pseudo - TTY ) for a given container . Blocks until the user exits the PTY .
def interact(self, container: Container) -> None:
        """
        Connects to the PTY (pseudo-TTY) for a given container.
        Blocks until the user exits the PTY.
        """
        cmd = "/bin/bash -c 'source /.environment && /bin/bash'"
        cmd = "docker exec -it {} {}".format(container.id, cmd)
        subprocess.call(cmd, shell=True)