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

Code Example 1

sudo docker attach Container_Name

Code Example 2

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

Learn ReactJs, React Native from akashmittal.com