To run a command on an already existing Docker container by running below-mentioned command but you have to be knowing its ID (or name):
docker exec -it <container_id_or_name> echo "Hello from container!"
Another point to note that exec command works only on already running container. If the container is currently stopped, then you will need to run it first with the following command:
docker run -it -d shykes/pybuilder /bin/bash
The most important thing to keep in mind here is the -d option, which stands for detached. It means that the command you initially provided to the container (/bin/bash) will be run in the background and the container will not stop immediately.