Skip to content
Snippets Groups Projects
Commit bfbbef4a authored by nimrod's avatar nimrod
Browse files

Control output from docker-remote.

So now I can run `$(eval docker remote hostname)`.
parent a60a7eff
Branches
No related tags found
No related merge requests found
#!/bin/sh #!/bin/sh
set -eu set -eu
[ -n "$1" ] || { echo "You must specify host." >&2; exit 1; } [ -n "$1" ] || { echo "You must specify host." >&2; exit 1; }
host="$1" host="$1"
localsocket="$HOME/.ssh/docker_$host.sock" localsocket="$HOME/.ssh/docker_$host.sock"
lsof -t "$localsocket" > /dev/null || rm "$localsocket" lsof -t "$localsocket" > /dev/null 2>&1 || rm -f "$localsocket"
forward "$host" "$localsocket:/var/run/docker.sock" forward "$host" "$localsocket:/var/run/docker.sock" > /dev/null 2>&1
# Echo the DOCKER_HOST export command, for eval'ing. # Echo the DOCKER_HOST export command, for eval'ing.
echo "export DOCKER_HOST=unix://$localsocket" echo "export DOCKER_HOST=unix://$localsocket"
...@@ -10,6 +10,10 @@ forward="$2" || { usage >&2; exit 1; } ...@@ -10,6 +10,10 @@ forward="$2" || { usage >&2; exit 1; }
alias ssh='ssh -fnNTS ~/.ssh/%C.sock' alias ssh='ssh -fnNTS ~/.ssh/%C.sock'
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh -o ControlMaster=auto -o ControlPersist=0 -o ExitOnForwardFailure=no -o ControlPersist=0 "$host" ssh -o ControlMaster=auto \
-o ControlPersist=0 \
-o ExitOnForwardFailure=no \
-o ControlPersist=0 \
"$host"
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh -O forward -L "$forward" "$host" ssh -O forward -L "$forward" "$host"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment