Esempio n. 1
0
 def install(self, *args, **kwargs):
     try:
         get_image(self.docker_client,
                   image_id=self.image_id,
                   repo=self.uri)
     except APIError as e:
         if e.response.status_code == 404:
             log.info('Image %s not found:' % self.image_id)
             raise RuntimeError('Image %s not found:' % self.image_id)
Esempio n. 2
0
def run_container(client, from_img, kwargs, container_kwargs):

    cmd = kwargs.pop("cmd", None)
    if not cmd:
        raise RabixError("Commands ('cmd') not specified!")

    repo, tag = parse_repository_tag(from_img)
    img = get_image(client, from_img)
    if not img:
        raise RabixError("Unable to find image: %s" % img)

    mount_point = kwargs.pop("mount_point", MOUNT_POINT)
    run_cmd = make_cmd(cmd, join=True)

    container = Container(
        client,
        img["Id"],
        "{}:{}".format(repo, tag),
        run_cmd,
        volumes={mount_point: {}},
        working_dir=mount_point,
        **container_kwargs
    )

    container.start({abspath("."): mount_point})
    container.write_stdout()
    return container
Esempio n. 3
0
def run_container(client, from_img, kwargs, container_kwargs):

    cmd = kwargs.pop('cmd', None)
    if not cmd:
        raise RabixError("Commands ('cmd') not specified!")

    repo, tag = parse_repository_tag(from_img)
    img = get_image(client, from_img)
    if not img:
        raise RabixError("Unable to find image: %s" % img)

    mount_point = kwargs.pop('mount_point', MOUNT_POINT)
    run_cmd = make_cmd(cmd, join=True)

    container = Container(client,
                          img['Id'],
                          "{}:{}".format(repo, tag),
                          run_cmd,
                          volumes={mount_point: {}},
                          working_dir=mount_point,
                          **container_kwargs)

    container.start({abspath('.'): mount_point})
    container.write_stdout()
    return container
Esempio n. 4
0
    def install(self, *args, **kwargs):

        image = get_image(
            self.docker_client,
            image_id=self.image_id,
            repo=self.uri
        )

        if not image:
            log.info('Image %s not found:' % self.image_id)
            raise RabixError('Image %s not found:' % self.image_id)

        if not image['Id'].startswith(self.image_id):

            raise RabixError(
                'Wrong id of pulled image: expected "%s", got "%s"'
                % (self.image_id, image['Id'])
            )

        self.image_id = image['Id']