Ejemplo n.º 1
0
def images(ctx, force, all):
    """clean docker images which has no tag"""
    ctx.log('clean untag images')
    untag_images = docker.images('--format','{{.ID}}',
                                 "--filter=dangling=true", '-q').split()
    remove_images(ctx, untag_images, force)
    if all:
        ctx.log('clean all images')
        all_images = docker.images('--format','{{.Repository}}:{{.Tag}}',
                                   '-q').split()
        remove_images(ctx, all_images)

    ctx.log('list all images')
    print(docker.images())
Ejemplo n.º 2
0
def images(ctx, force, all):
    """clean docker images which has no tag"""
    ctx.log('clean untag images')
    untag_images = docker.images('--format', '{{.ID}}',
                                 "--filter=dangling=true", '-q').split()
    remove_images(ctx, untag_images, force)
    if all:
        ctx.log('clean all images')
        all_images = docker.images('--format', '{{.Repository}}:{{.Tag}}',
                                   '-q').split()
        remove_images(ctx, all_images)

    ctx.log('list all images')
    print(docker.images())
Ejemplo n.º 3
0
    def __build_base_image(self, config):
        # This does not seem to be the right way to get the container tag?
        self.container_tag = config.get_container_tag()
        all_images = docker.images(a=True)

        import pdb; pdb.set_trace()

        if self.container_tag in all_images:
            return

        print ("Container not found or changes in watched files. Rebuilding base container (%s)..." % self.container_tag)

        base_name = 'nose-docker-base-%s' % self.container_tag

        all_containers = docker.ps(a=True)
        if base_name in all_containers:
            docker.rm('-f', base_name)

        docker.run(
            '--name=%s' % base_name, 
            '-v',
            '%s:/app' % abspath(os.curdir),
            config.base_image,
            '/bin/bash',
            c="cd /app && %s" % (
                " && ".join(config.build_commands)
            ),
            _out=sys.stdout
        )
        docker.commit('nose-docker-base-%s' % self.container_tag, 'nose-docker:%s' % self.container_tag)
Ejemplo n.º 4
0
    def __build_base_image(self, config):
        # This does not seem to be the right way to get the container tag?
        self.container_tag = config.get_container_tag()
        all_images = docker.images(a=True)

        import pdb
        pdb.set_trace()

        if self.container_tag in all_images:
            return

        print(
            "Container not found or changes in watched files. Rebuilding base container (%s)..."
            % self.container_tag)

        base_name = 'nose-docker-base-%s' % self.container_tag

        all_containers = docker.ps(a=True)
        if base_name in all_containers:
            docker.rm('-f', base_name)

        docker.run('--name=%s' % base_name,
                   '-v',
                   '%s:/app' % abspath(os.curdir),
                   config.base_image,
                   '/bin/bash',
                   c="cd /app && %s" % (" && ".join(config.build_commands)),
                   _out=sys.stdout)
        docker.commit('nose-docker-base-%s' % self.container_tag,
                      'nose-docker:%s' % self.container_tag)
Ejemplo n.º 5
0
def cli(ctx, images, private_registry):
    """pull images from private registry

    images could be a list param
    """
    ctx.log('pull %s from %s' % (images, private_registry))
    for image in images:
        pulled_image = parse_image(image, private_registry)
        ctx.log('RUN: docker pull %s' % pulled_image)
        try:
            docker.pull(pulled_image)
            if private_registry:
                docker.tag(pulled_image, image)
                docker.rmi(pulled_image)
        except:
            ctx.log('failed pull %s' % image)

    print(docker.images())
Ejemplo n.º 6
0
def cli(ctx, images, all, private_registry):
    """push images to private registry

    images could be a list param
    """
    if all:
        images = docker.images('--format','{{.Repository}}:{{.Tag}}')
        images = images.split()
        print(images)
    ctx.log('push %s to %s' % (images, private_registry or 'DockerHub'))
    for image in images:
        ctx.log('RUN: docker push %s' % image)
        if private_registry:
            new_image = '%s/%s' % (private_registry, image)
            docker.tag(image, new_image)
            print(docker.push(new_image))
            docker.rmi(new_image)
        else:
            print(docker.push(image))
Ejemplo n.º 7
0
def cli(ctx, images, all, private_registry):
    """push images to private registry

    images could be a list param
    """
    if all:
        images = docker.images('--format', '{{.Repository}}:{{.Tag}}')
        images = images.split()
        print(images)
    ctx.log('push %s to %s' % (images, private_registry or 'DockerHub'))
    for image in images:
        ctx.log('RUN: docker push %s' % image)
        if private_registry:
            new_image = '%s/%s' % (private_registry, image)
            docker.tag(image, new_image)
            print(docker.push(new_image))
            docker.rmi(new_image)
        else:
            print(docker.push(image))
Ejemplo n.º 8
0
def return_current_package_image(package: str,
                                 fuzzer_image: str,
                                 package_image: str,
                                 json_output_path: str = None,
                                 qemu=False,
                                 timeout=None) -> str:
    """
    Checks if the current package_image still exists and if not creates a new one.
    """
    output = str(docker.images(package_image))
    print(output.split("\n"))
    if len(output.split("\n")) > 2:
        return package_image
    else:
        return build_and_commit(package,
                                fuzzer_image=fuzzer_image,
                                json_output_path=json_output_path,
                                qemu=qemu,
                                timeout=timeout)
Ejemplo n.º 9
0
 def check_if_base_image_exists() -> bool:
     if "githubfuzzer" in str(docker.images("-a")):
         return True
     else:
         return False