Skip to content

Instantly share code, notes, and snippets.

@sudo-bmitch
Last active November 9, 2018 14:52
Show Gist options
  • Save sudo-bmitch/67ec4739a2f615a038151a3c852cc01f to your computer and use it in GitHub Desktop.
Save sudo-bmitch/67ec4739a2f615a038151a3c852cc01f to your computer and use it in GitHub Desktop.
Docker SSH Remote Setup

Assumptions: remote host is running an older docker version, on Linux, and the user shell is bash.

This script is used to setup a remote docker host running an engine prior to 18.09 to allow remote docker ssh based access. It will upgrade the docker client used by the specific user to 18.09, placing the client binary in $HOME/bin/docker and updating .bashrc to prioritize $HOME/bin over the rest of the path. Once run on the remote host, you can connect to it from another docker 18.09 or newer client over ssh using:

docker -H ssh://host info

or

export DOCKER_HOST=ssh://host
docker info
#!/bin/sh
set -e
mkdir -p $HOME/bin
sed -i '1s;^;export PATH=$HOME/bin:$PATH\n;' $HOME/.bashrc
tmpdir=$(mktemp -d)
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-18.09.0.tgz \
| tar -C "$tmpdir" -xz docker/docker
mv "$tmpdir/docker/docker" $HOME/bin/docker
if [ -n "$tmpdir" -a -d "$tmpdir" ]; then
rm -r "$tmpdir"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment