When there’s a running docker container and you need to execute some code in it through the terminal, you need to enter it first.

1. To enter the container, get its name first. in the terminal type:

docker ps

and you’ll get an output of the currently running containers, including some stupid name like fastidious_fruitfly or jungle_beaver. That’s the name of the container you want to enter.

2. Enter the container with the following code (substitute in whatever your container’s name is):

docker exec -ti fastidious_fruitfly /bin/bash

3. And voila! you’re now inside the docker container’s ecosystem, able to run bash commands.