You can use this docker container to create a SSH tunnel to a remote machine and have it "visible" inside your docker environment.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
|
||
---|---|---|
.drone.yml | ||
Dockerfile | ||
LICENSE | ||
README.md | ||
entrypoint.sh |
README.md
docker-sshtunnel
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