diff --git a/library/cloud/docker b/library/cloud/docker index 23c88e5184..0b12f5535b 100644 --- a/library/cloud/docker +++ b/library/cloud/docker @@ -197,6 +197,14 @@ options: default: false aliases: [] version_added: "1.8" + registry: + description: + - The remote registry URL to use for pulling images. + required: false + default: '' + aliases: [] + version_added: "1.8" + author: Cove Schneider, Joshua Conner, Pavel Antonov requirements: [ "docker-py >= 0.3.0", "docker >= 0.10.0" ] ''' @@ -499,13 +507,6 @@ class DockerManager: def get_split_image_tag(self, image): if '/' in image: image = image.split('/')[-1] - tag = None - if image.find(':') > 0: - return image.split(':') - else: - return image, tag - - def get_split_full_image_tag(self, image): tag = "latest" if image.find(':') > 0: return image.split(':') @@ -611,8 +612,13 @@ class DockerManager: try: containers = do_create(count, params) except: - image, tag = self.get_split_full_image_tag(params['image']) - self.client.pull(image, tag = tag) + image, tag = self.get_split_image_tag(params['image']) + if self.module.params.get('username'): + self.client.login(self.module.params.get('username'), + password=self.module.params.get('password'), + email=self.module.params.get('email'), + registry=self.module.params.get('registry')) + self.client.pull(image, tag=tag) self.increment_counter('pull') containers = do_create(count, params) @@ -700,9 +706,10 @@ def main(): memory_swap = dict(default=0), docker_url = dict(default='unix://var/run/docker.sock'), docker_api_version = dict(default=docker.client.DEFAULT_DOCKER_API_VERSION), - user = dict(default=None), + username = dict(default=None), password = dict(), email = dict(), + registry = dict(), hostname = dict(default=None), env = dict(type='dict'), dns = dict(),