You can use this docker container to create a SSH tunnel to a remote machine and have it "visible" inside your docker environment.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Paolo Asperti d7fafd0928
initial release
4 weeks ago
.drone.yml initial release 4 weeks ago
Dockerfile initial release 4 weeks ago
LICENSE Initial commit 4 weeks ago
README.md initial release 4 weeks ago
entrypoint.sh initial release 4 weeks ago

README.md

docker-sshtunnel

Build Status

You can use this docker container to create a SSH tunnel to a remote machine and have it "visible" inside your docker environment.

Usage example

With the following settings, you have a container that establishes an SSH session with the specified remote machine, forwards remote mysql port to a port on the local container itself which is then exported by the local docker.

That way you can connect to a remote mysql server (even if not directly exposed) as if it is running on your machine.

Plain docker

docker run --rm -ti \
    -e SSH_USER=root \
    -e SSH_HOST=myremoteserver.mydomain.com \
    -e REMOTE_PORT=3306 \
    -e LOCAL_PORT=3306 \
    -e REMOTE_HOST=127.0.0.1 \
    -p 3306:3306 \
    -v /home/me/.ssh/id_rsa:/id_rsa \
    --name stu \
    docker.asperti.com/paspo/sshtunnel:latest

docker-compose

version: "3"
services:

  backup-slave:
    image: docker.asperti.com/paspo/sshtunnel:latest
    restart: unless-stopped
    volumes:
      - "/home/me/.ssh/id_rsa:/id_rsa"
    environment:
      - SSH_USER=root
      - SSH_HOST=myremoteserver.mydomain.com
      - REMOTE_PORT=3306
      - LOCAL_PORT=3306
      - REMOTE_HOST=127.0.0.1
    ports:
      - 3306:3306