Skip to content

Instantly share code, notes, and snippets.

@u1i
Created September 8, 2017 10:25
Show Gist options
  • Save u1i/7b2103e4d77410c357f2655886bc0b17 to your computer and use it in GitHub Desktop.
Save u1i/7b2103e4d77410c357f2655886bc0b17 to your computer and use it in GitHub Desktop.
import os
from docker import Client
from docker.utils import kwargs_from_env
kwargs = kwargs_from_env()
#kwargs['tls'].assert_hostname = False
client = Client(**kwargs)
containers = client.containers()
# get all containers that are based on this image
seleniums = [c for c in containers if c['Image'] == 'u1ih/ubuntu']
# get all the published ports
urls = [s['Ports'][0]['IP'] + ':' + str(s['Ports'][0]['PublicPort']) for s in seleniums]
print urls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment