How do I run execute commands from a git repo from Python? Shell + Docker

My goal is to run a docker container that will simulate a physical device that sends requests to an external API.

The simulator lives in a GitHub repo and after cloning it is run by bash scripts that:

  1. Set up a virtualenv.
  2. Run maven build.
  3. Execute other commands via Python that runs a docker container.
  4. It can also remove docker container.

How can I simplify these dependencies and make sure everything is packed in a working container (application that otherwise would be run through shell scripts)?

Source: Docker Questions