项目作者: ruanbekker

项目描述 :
Run Remote Docker commands via a SSH Tunnel
高级语言: Shell
项目地址: git://github.com/ruanbekker/docker-remote-tunnel.git
创建时间: 2019-03-10T16:13:51Z
项目社区:https://github.com/ruanbekker/docker-remote-tunnel

开源协议:

下载


docker-remote-tunnel

ruan.ru.bekker@gmail.com">Say Thanks!

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

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

  1. $ docker run -v ~/.ssh/id_rsa:/tmp/key -it ruanbekker/docker-remote-tunnel sh

Wrapper supports creating and terminating the tunnels:

  1. $ docker-tunnel --help
  2. Usage: /usr/bin/docker-tunnel
  3. Description: Execute remote docker commands via ssh tunnel over a docker socket
  4. -h, --help Display usage instructions
  5. -c, --connect [user@foo.bar] Establishes Tunnel to Remote SSH Server. Expects username@remote-server
  6. -t, --terminate Terminates Tunnel

Establish a SSH Tunnel to your Manager node:

  1. $ docker-tunnel -c root@manager.docker.example.com
  2. Source the environment either with:
  3. 1) source /root/.docker-tunnel.sh
  4. 2) export DOCKER_HOST="localhost:2376"

Source the environment:

  1. $ source /root/.docker-tunnel.sh

Validate that the DOCKER_HOST variable has been set:

  1. $ env | grep DOCKER
  2. DOCKER_HOST=localhost:2376

Run a docker command from the container:

  1. $ docker node ls
  2. ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
  3. 9kbmvcr73ceh2afozxrwx3CzT * swarm-manager-1 Ready Active Leader 18.06.3-ce
  4. vuxEvsv09qvRekwcltk7prmkx swarm-worker-1 Ready Active 18.06.3-ce

Terminate the tunnel:

  1. $ docker-tunnel --terminate

Verify that the tunnel has been terminated:

  1. $ docker node ls
  2. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Docker Hub Image