Last active
May 24, 2021 15:33
-
-
Save mikeslattery/1abb25be79bf43baa9045297e03021b7 to your computer and use it in GitHub Desktop.
Run docker over ssh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Usage (local use): docker-over-ssh <server> | |
#Usage (expose): endpoint=0.0.0.0 docker-over-ssh <server> | |
endpoint="${endpoint:-localhost}" | |
ssh -nNT -L $endpoint:2375:/var/run/docker.sock "$1" & | |
export DOCKER_HOST=tcp://$endpoint:2375 | |
echo "Now your docker commands will run on $1" | |
echo "To stop, run 'exit'" | |
"$SHELL" -i | |
jobs -p | xargs -r kill || true | |
wait | |
echo "Remote docker connection killed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This starts a daemon that allows you to run docker client commands locally against a docker engine running remotely.
If you are running a docker engine locally, you should stop it before running this.