Check out example codes for "ssh into docker container". It will help you in understanding the concepts better.

Code Example 1

docker exec -it [container-id] bash

Code Example 2

docker exec -it <mycontainer> bash
docker exec -it <mycontainer> sh ##for alpine

Code Example 3

sudo docker exec –it nginx-test /bin/bash

Code Example 4

docker exec -it nginx /bin/bash

Code Example 5

docker exec -it <container name> /bin/bash

Code Example 6

sudo docker attach Container_Name

Learn ReactJs, React Native from akashmittal.com