From 00be6a4cf8fa5c5d3a8d9e56ae3bb640f35104e0 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sun, 28 Apr 2019 09:37:17 +0300 Subject: [PATCH] Use forward in docker-remote. --- Documents/bin/_docker-remote | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Documents/bin/_docker-remote b/Documents/bin/_docker-remote index ff289e9..62a5421 100755 --- a/Documents/bin/_docker-remote +++ b/Documents/bin/_docker-remote @@ -1,24 +1,13 @@ #!/bin/sh set -eu + [ -n "$1" ] || { echo "You must specify host." >> /dev/stderr; exit 1; } host="$1" localsocket="$HOME/.ssh/docker_$host.sock" -ssh="ssh -fnNTS ~/.ssh/%C.sock" - -# Check for exiting forward -if ! $ssh -O check -L "$localsocket:/var/run/docker.sock" "$host" 2> /dev/null -then - - # Delete socket if it exists - [ ! -S "$localsocket" ] || rm "$localsocket" - - # Open SSH ControlMaster - $ssh -o ExitOnForwardFailure=no -o ControlMaster=auto -o ControlPersist=0 "$host" - # Forward socket - $ssh -O forward -L "$localsocket:/var/run/docker.sock" "$host" -fi +lsof -t "$localsocket" > /dev/null || rm "$localsocket" +forward "$host" "$localsocket:/var/run/docker.sock" # Echo the DOCKER_HOST export command, for eval'ing. echo "export DOCKER_HOST=unix://$localsocket" -- GitLab