How to setup SSH access to a docker container?

I am running a docker container within an EC2 instance, How to ssh into the docker container directly without having to login to the container host i.e the EC2 instance here everytime?

  • Deleting all docker images and containers
  • Can't push or pull to/from docker registry on localhost
  • Is it safe to extract the root filesystem of a Docker.io image and use it in a chroot?
  • Jenkins docker plugin + commit docker slave, how to push it to a external registry. Image saved on docker host configured in cloud template
  • Unable to Pull image from quay.io: ERROR x509: certificate signed by unknown authority
  • Docker Swarm Service-Task not running
  • What is the purpose of the Docker build context?
  • dockerizing wordpress with mysql installed on the host machine
  • Do I always need to rebuild docker in order to install new pip packages?
  • Docker images/containers taking up space despite clean up
  • How to setup docker to talk to non-dockerized service on same host
  • hazelcast docker container can't run continuously
  • One Solution collect form web for “How to setup SSH access to a docker container?”

    There an example of setting up SSH service on the docker documentation.

    https://docs.docker.com/examples/running_ssh_service/

    Once you have the IP of the host and the port mapped to port 22 of the container, you should be able to ssh

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.