Skip to content

Instantly share code, notes, and snippets.

@alexkunin
Created October 22, 2018 11:49
Show Gist options
  • Save alexkunin/dd47053190473b7d7e3a2e9480943096 to your computer and use it in GitHub Desktop.
Save alexkunin/dd47053190473b7d7e3a2e9480943096 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
HOST=remote.host
IFACE=127.0.0.1
PORT=1234
SOCKET=remote-docker-socket.${HOST}
ssh -M -S ${SOCKET} -o ExitOnForwardFailure=yes -fNTL ${IFACE}:${PORT}:/var/run/docker.sock ${HOST} && (
DOCKER_HOST=tcp://${IFACE}:${PORT} docker-compose $*
ssh -S ${SOCKET} -O exit ${HOST} 2> /dev/null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment