在Docker容器之间连接Scality/S3服务器

4
我们正在使用基于Python的解决方案,该方案将从S3加载和存储文件。为了开发和本地测试,我们使用带有Docker和Docker Compose的Vagrant环境。我们有两个Docker Compose定义——一个用于辅助后端服务(Mongo、Restheart、Redis和S3),另一个包含基于Python的REST API,使用后端服务暴露解决方案。

当我们的“前端”Docker Compose组与Restheart交互时,这很好运作(在http调用中使用restheart容器的名称作为服务器主机名)。但是,当我们对scality/s3服务器执行相同操作时,却无法正常工作。

有趣的部分是,我们已经创建了一个测试套件,用于从主机(windows10)上运行的Python测试套件中使用通过Vagrant转发到Docker Compose组内的scality/s3服务器的docker容器的端口。我们使用的endpoint_url是localhost,它完美地工作。

在错误情况下(当前端Web服务想要写入S3时),“前端”服务总是响应: botocore.exceptions.ClientError: An error occurred (InvalidURI) when calling the CreateBucket operation: Could not parse the specified URI. Check your restEndpoints configuration. 而s3server总是以http 400响应并显示以下消息:

s3server | {"name":"S3","clientIP":"::ffff:172.20.0.7","clientPort":49404,"httpMethod":"PUT","httpURL":"/raw-data","time":1521306054614,"req_id":"e385aae3c04d99fc824d","level":"info","message":"received request","hostname":"cdc8a2f93d2f","pid":83} s3server | {"name":"S3","bytesSent":233,"clientIP":"::ffff:172.20.0.7","clientPort":49404,"httpMethod":"PUT","httpURL":"/raw-data","httpCode":400,"time":1521306054639,"req_id":"e385aae3c04d99fc824d","elapsed_ms":25.907569,"level":"info","message":"responded with error XML","hostname":"cdc8a2f93d2f","pid":83}

我们使用以下boto3代码调用scality:

    s3 = boto3.resource('s3',
                        aws_access_key_id='accessKey1',
                        aws_secret_access_key='verySecretKey1',
                        endpoint_url='http://s3server:8000')
    s3_client = boto3.client('s3',
                             aws_access_key_id='accessKey1',
                             aws_secret_access_key='verySecretKey1',
                             endpoint_url='http://s3server:8000')

    s3.create_bucket(Bucket='raw-data') # here the exception comes
    bucket = self.s3.Bucket('raw-data')
1个回答

5
这个问题很常见。在您挂载到Docker容器中的config.json文件中,我假设有一个restEndpoints部分,在那里您必须将域名与默认区域关联起来。这意味着您的前端域名应该在其中指定,并匹配一个默认区域。
请注意,该默认区域并不会阻止您使用其他区域:如果您没有另外指定,那么您的存储桶将在该区域创建。
将来,建议您直接在Zenko论坛上开启问题,因为这里是大多数社区和核心开发人员所在的地方。
祝好,
Laure

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接