Skip to content

Instantly share code, notes, and snippets.

@hamiltont
Created April 17, 2014 03:15
Show Gist options
  • Save hamiltont/10950399 to your computer and use it in GitHub Desktop.
Save hamiltont/10950399 to your computer and use it in GitHub Desktop.
Small example of docker remote api over ssh tunnel
import docker
import bgtunnel
import sys
def list_images(target_host):
print('Targeting %s' % target_host)
forwarder = bgtunnel.open(ssh_user="hamiltont",
silent=True,
ssh_address=target_host,
host_port=5555,
identity_file="/home/hamiltont/.ssh/id_rsa",
expect_hello=False)
client = docker.Client(base_url="http://127.0.0.1:%d"
% forwarder.bind_port)
return client.images()
if __name__ == '__main__':
print list_images(sys.argv[1])
@ssssam
Copy link

ssssam commented Jul 2, 2014

Very useful and helpful! Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment