put_archive与python马拉松docker应用程序?

我猜想,我想要做的是不可能的devise,但certificate我错了。

对于我们的一个后端,我们使用python marathon客户端来pipe理mesos群集上的docker容器。 我想要做的是一旦它启动,dynamic添加一个文件到docker容器。 使用普通的docker客户端,我会做这样的事情:

def create_archive(file_contents, file_name): """ doc """ tarstream = io.BytesIO() with tarfile.open(fileobj=tarstream, mode='w') as tarfile_: encoded_file_contents = file_contents.encode('utf8') tarinfo = tarfile.TarInfo(file_name) tarinfo.size = len(encoded_file_contents) tarinfo.mtime = time.time() tarfile_.addfile(tarinfo, io.BytesIO(encoded_file_contents)) logger.info("[+] Successfully created tarfile {}".format(file_name)) # We're at the end of the tarstream, go back to the beginning. return tarstream.seek(0) def add_docker_archive(docker_client, container_id, content, dest): """ doc """ logger.debug( "[DB] About to put content {} to {} in container with ID {}".format( content, dest, container_id) ) try: docker_client.put_archive( container=container_id, path=dest, data=content ) except Exception as e: logger.error( "[-] Failed to put archive into container {}. {}".format( container_id, e ) ) pass client = Client("tcp://{}:{}".format( settings.DOCKER_HOST, settings.DOCKER_PORT)) client.create_container(**container_data) content = create_archive('this is my data') add_docker_archive(client, container_id, content, settings.OUTPUT_DIR) 

是否有可能做一个类似的马拉松docker应用程序? 在python-marathon的源代码中,似乎只能dynamic地设置卷映射和环境variables。