Created
April 17, 2014 03:15
-
-
Save hamiltont/10950399 to your computer and use it in GitHub Desktop.
Small example of docker remote api over ssh tunnel
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
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful and helpful! Thanks for this!