def run_code_in_container(cli, image, code, mount, entrypoint):
kwargs = {<EOL>'<STR_LIT:image>': image,<EOL>}<EOL>if entrypoint:<EOL><INDENT>kwargs['<STR_LIT>'] = '<STR_LIT>'<EOL>kwargs['<STR_LIT>'] = '<STR_LIT>'.format(quote(code))<EOL><DEDENT>else:<EOL><INDENT>kwargs['<STR_LIT>'] = '<STR_LIT>'.format(quote(code))<EOL><DEDENT>if mount:<EOL><INDENT>binds = []<EOL>volumes = []<EOL>for m in mount:<EOL><INDENT>part = m.split('<STR_LIT::>')<EOL>if len(part) == <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>elif len(part) == <NUM_LIT:2>:<EOL><INDENT>part.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT>src, target, mode = part<EOL>src = os.path.abspath(os.path.expanduser(src))<EOL>binds.append('<STR_LIT>'.format(src, target, mode))<EOL>volumes.append(target)<EOL><DEDENT>kwargs['<STR_LIT>'] = cli.create_host_config(binds=binds)<EOL>kwargs['<STR_LIT>'] = volumes<EOL><DEDENT>container = cli.create_container(**kwargs)<EOL>container_id = container['<STR_LIT>']<EOL>cli.start(container=container_id)<EOL>return container_id<EOL>
Run `code` in a container, returning its ID