links: Docker MOC


How to SSH into a running container

  • List containers user docker ps
  • Connect to container with the following command
docker exec -it <container-name> /bin/bash
  • Generic usage
docker exec -it <container-name> <command>

How to run a command in container

docker compose run <conatiner name> <command>

Example to connect to container

docker compose run web /bin/bash

This will open bash terminal for web container


tags: docker ssh

sources: