links: [[Docker MOC]] --- # How to SSH into a running container - List containers user `docker ps` - Connect to container with the following command ```sh docker exec -it <container-name> /bin/bash ``` - Generic usage ```sh docker exec -it <container-name> <command> ``` # How to run a command in container ```sh docker compose run <conatiner name> <command> ``` Example to connect to container ```sh docker compose run web /bin/bash ``` This will open bash terminal for web container --- tags: #docker #ssh sources: - [SSH into a container](https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/)