SSH tunneling to remote server with docker

I am trying to write a Dockerfile to access a remote mySQL database using ssh tunneling.

Tried with the following Run command:

  • HBase on docker NotServingRegionException because of hostname alisas
  • Remove existing image when using `docker commit`?
  • Can docker run inside a Linux Container?
  • How to log container in docker swarm mode
  • How to pass command line arguments in kubernetes?
  • Best way to run two docker compose apps behind nginx on one host machine?
  • ssh   -f -N username@hostname -L [local port]:[database host]:[remote port] StrictHostKeyChecking=no

    and getting this error:

    “Host key verification failed” ERROR

  • Combining salt, docker and Amazon EC2 for hosting Python application
  • How to access a host port (bind with ssh -R) from a container?
  • Docker centos:6 mounting webdav client with ec2 loadbalancer webdav server
  • docker 1.7.0 under ubuntu14.04,can not run a container,error message “device or resourcebusy ”
  • docker-compose creates file owned by root
  • Eval command not found when completing the Docker for Windows tutorial
  • One Solution collect form web for “SSH tunneling to remote server with docker”

    Assuming that the Docker container does not have access to any SSH data (i.e.: there is no ~/.ssh/known_hosts), you have two ways to handle this:

    1. Use ssh-keyscan -t rsa > ~/.ssh/my_known_hosts from within the container to add the remote host
    2. Or copy the relevant line from an existing my_known_hosts or simply COPY a the whole file to the container.

    Either of these approaches should do it.

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