def with_ephemeral_container(images=None, verbose=False, privileged=False):
if not images:<EOL><INDENT>images = []<EOL><DEDENT>def decorator(func):<EOL><INDENT>def wrapper(*args, **kwargs):<EOL><INDENT>for image in images:<EOL><INDENT>c1 = docker_run(image=image, privileged=privileged)<EOL>hs = build_host_string(c1, env.docker_host)<EOL>if verbose:<EOL><INDENT>fabric_flags = show('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>fabric_flags = hide('<STR_LIT>')<EOL><DEDENT>with settings(fabric_flags, host_string=hs):<EOL><INDENT>try:<EOL><INDENT>print("<STR_LIT>" % (<EOL>func.func_name, image))<EOL>func(*args, **kwargs)<EOL>docker_rm(c1)<EOL><DEDENT>except:<EOL><INDENT>docker_rm(c1)<EOL>raise<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
A decorator that creates ephemeral docker containers, executes the
wrapped function and destroys the docker container.

takes a list of docker images, and executes the wrapped function for each
one of those images.

params:
    list images: array containing a list of docker images
    bool verbose: print out debug information
    bool privileged: run the docker instance in privileged mode