Example #1
0
def main():
    httpd = socketserver.TCPServer(('', PORT), OldRemoteHandler)

    crython.start()
    httpd.serve_forever()
Example #2
0
        'dead',
    ]

    containers_all = client.containers.list(all=True)

    # def filter_whitelisted(c) -> bool:
    #     try:
    #         return not set(c.image.tags) & set(blacklist_images)
    #     except:
    #         return True

    def filter_non_running(c) -> bool:
        return c.status in non_running_statuses

    def filter_old(c) -> bool:
        run_time = datetime.datetime.strptime(c.attrs['Created'][0:18], '%Y-%m-%dT%H:%M:%S')
        return run_time < datetime.datetime.now() - datetime.timedelta(seconds=container_expired_sec)

    containers_to_rem = list(filter(lambda x: all(f(x) for f in (filter_non_running, filter_old)), containers_all))

    for c in containers_to_rem:
        c.remove()
        print('Removed container {}'.format(c.name))


if __name__ == '__main__':
    crython.start()
    print("Starting autoclean containers with '{}', images with '{}' ...".format(clean_containers_expr,
                                                                                 clean_images_expr))
    crython.join()  ## This will block
 def start(self):
     crython.start()
     crython.join()