https://github.com/ruanbekker/docker-remote-tunnel
Run Remote Docker commands via a SSH Tunnel
https://github.com/ruanbekker/docker-remote-tunnel
cicd devops devops-tools docker docker-swarm ssh ssh-tunnel tooling
Last synced: about 1 year ago
JSON representation
Run Remote Docker commands via a SSH Tunnel
- Host: GitHub
- URL: https://github.com/ruanbekker/docker-remote-tunnel
- Owner: ruanbekker
- Created: 2019-03-10T16:13:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-25T23:41:49.000Z (about 6 years ago)
- Last Synced: 2025-04-17T02:14:42.338Z (about 1 year ago)
- Topics: cicd, devops, devops-tools, docker, docker-swarm, ssh, ssh-tunnel, tooling
- Language: Shell
- Size: 8.79 KB
- Stars: 3
- Watchers: 3
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# docker-remote-tunnel
[](https://saythanks.io/to/ruan.ru.bekker@gmail.com) [](https://microbadger.com/images/ruanbekker/docker-remote-tunnel "Get your own image badge on microbadger.com") [](https://microbadger.com/images/ruanbekker/docker-remote-tunnel "Get your own version badge on microbadger.com") 
Run Remote Docker commands via a SSH Tunnel
## Docker Remote Tunnel
Run Remote Docker commands via a SSH Tunnel. [Docker Hub: ruanbekker/docker-remote-tunnel](https://hub.docker.com/r/ruanbekker/docker-remote-tunnel)
## Description
I made this wrapper to simplify ci/cd deployments with concourse to deploy applications to docker swarm.
The wrapper creates a screen session, creates a ssh tunnel and mounting a local port to the docker socket on the manager node, allowing us to run docker commands locally, interfacing with the remote docker api.
## Usage:
Run a container, and map the path to your ssh key
```
$ docker run -v ~/.ssh/id_rsa:/tmp/key -it ruanbekker/docker-remote-tunnel sh
```
Wrapper supports creating and terminating the tunnels:
```
$ docker-tunnel --help
Usage: /usr/bin/docker-tunnel
Description: Execute remote docker commands via ssh tunnel over a docker socket
-h, --help Display usage instructions
-c, --connect [user@foo.bar] Establishes Tunnel to Remote SSH Server. Expects username@remote-server
-t, --terminate Terminates Tunnel
```
Establish a SSH Tunnel to your Manager node:
```
$ docker-tunnel -c root@manager.docker.example.com
Source the environment either with:
1) source /root/.docker-tunnel.sh
2) export DOCKER_HOST="localhost:2376"
```
Source the environment:
```
$ source /root/.docker-tunnel.sh
```
Validate that the DOCKER_HOST variable has been set:
```
$ env | grep DOCKER
DOCKER_HOST=localhost:2376
```
Run a docker command from the container:
```
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
9kbmvcr73ceh2afozxrwx3CzT * swarm-manager-1 Ready Active Leader 18.06.3-ce
vuxEvsv09qvRekwcltk7prmkx swarm-worker-1 Ready Active 18.06.3-ce
```
Terminate the tunnel:
```
$ docker-tunnel --terminate
```
Verify that the tunnel has been terminated:
```
$ docker node ls
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
```
## Docker Hub Image
- [Docker Hub: ruanbekker/docker-remote-tunnel](https://hub.docker.com/r/ruanbekker/docker-remote-tunnel)