小编Man*_*uel的帖子

将 docker 卷导出到另一台机器

我目前正在尝试将 redmine 与 postgres 数据库一起使用,但在设置环境时遇到了一些问题。

假设我有以下撰写文件

  db-redmine:
    image: 'bitnami/postgresql:11'
    user: root
    container_name: 'orchestrator_redmine_pg'
    environment:
      - POSTGRESQL_USERNAME=${POSTGRES_USER}
      - POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRESQL_DATABASE=${POSTGRES_DB}
      - BITNAMI_DEBUG=true
    volumes:
      - 'postgresql_data:/bitnami/postgresql'

  redmine:
    image: 'bitnami/redmine:4'
    container_name: 'orchestrator_redmine'
    ports:
      - '3000:3000'
    environment:
      - REDMINE_DB_POSTGRES=orchestrator_redmine_pg
      - REDMINE_DB_USERNAME=${POSTGRES_USER}
      - REDMINE_DB_PASSWORD=${POSTGRES_PASSWORD}
      - REDMINE_DB_NAME=${POSTGRES_DB}
      - REDMINE_USERNAME=${REDMINE_USERNAME}
      - REDMINE_PASSWORD=${REDMINE_PASSWORD}
    volumes:
      - 'redmine_data:/bitnami'
    depends_on:
      - db-redmine

volumes:
  postgresql_data:
    driver: local
  redmine_data:
    driver: local
Run Code Online (Sandbox Code Playgroud)

这会生成 redmine 的 postgres 数据库并创建 redmine 实例。

容器启动后,我进入 redmine 实例并配置应用程序,这意味着创建自定义字段、添加跟踪器、问题类型等。需要进行大量设置,所以我不想每次都这样做部署这种容器。

我想,因为所有设置数据都会进入卷,所以我可以导出这些卷,然后在新机器上导入它们。这样,当两个应用程序在新计算机上启动时,它们将获得先前设置中的所有必要信息。

这听起来很简单,但我在导出然后导入阶段遇到了困难。

根据我所看到的,我可以通过执行以下操作导出postgresql_data到文件:.tar

docker export postgresql_data --output="postgres_data.tar"
Run Code Online (Sandbox Code Playgroud)

但是如何将新生成的 …

docker docker-compose docker-volume

4
推荐指数
1
解决办法
5935
查看次数

使用 boto3 invoke() 时获取 AWS Lambda 响应

我目前正在编写一个与一些 AWS lambda 函数交互的 python 脚本。在其中一个函数中,我的响应包含我的脚本中需要的列表。

问题是,当我使用该invoke()函数时,响应是一个包含请求信息的 json。

response = aws_lambdaClient.invoke(FunctionName = 'functionName', Payload = payload)
Run Code Online (Sandbox Code Playgroud)

我使用的函数将此作为返回

return {'names': aList, 'status': 'Success!'}
Run Code Online (Sandbox Code Playgroud)

如果我打印出响应,我会得到:

{'ResponseMetadata': {'RequestId': 'xxxxxxxxx', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 07 Nov 2019 14:28:25 GMT', 'content-type': 'application/json', 'content-length': '51', 'connection': 'keep-alive', 'x-amzn-requestid': 'xxxxxxxxxx', 'x-amzn-remapped-content-length': '0', 'x-amz-executed-version': '$LATEST', 'x-amzn-trace-id': 'root=xxxxxxxxx;sampled=0'}, 'RetryAttempts': 0}, 'StatusCode': 200, 'ExecutedVersion': '$LATEST', 'Payload': <botocore.response.StreamingBody object at 0x0000023D15716048>}
Run Code Online (Sandbox Code Playgroud)

我喜欢得到

{'names': aList, 'status': 'Success!'}
Run Code Online (Sandbox Code Playgroud)

关于如何实现这一目标有什么想法吗?或者我应该找到另一种获取数据的方法(也许将我需要的列表放入 s3 存储桶中,然后从那里获取它)。

amazon-web-services boto3 aws-lambda

3
推荐指数
1
解决办法
1万
查看次数

使用 boto3 创建 aws lambda 集成 api 网关资源

正如标题所示,我试图用一种方法创建一个资源,该方法用boto3python 库触发 lambda 函数。

我在做以下事情。

首先,我创建资源

new_endpoint_response = aws_apigateway.create_resource(
        restApiId = 'xxxxxxxx',
        parentId = 'xxxxxxxx',
        pathPart = event['Configure']
    )
Run Code Online (Sandbox Code Playgroud)

然后,post方法

put_method_response = aws_apigateway.put_method(
        restApiId = 'xxxxxxxxxxx',
        resourceId = new_endpoint_response['id'],
        httpMethod = 'POST',
        authorizationType = 'NONE'
    )
Run Code Online (Sandbox Code Playgroud)

最后,将 lambda 函数分配给该方法

aws_apigateway.put_integration(
        restApiId = 'xxxxxxxxxx',
        resourceId = new_endpoint_response['id'],
        httpMethod = 'POST', 
        integrationHttpMethod = 'POST',
        type = 'AWS',
        uri = 'LAMBDA ARN'
    )
Run Code Online (Sandbox Code Playgroud)

这是我遇到一些问题的地方。当我尝试做最后一步时,我总是得到

An error occurred (BadRequestException) when calling the PutIntegration operation: AWS ARN for integration must contain path or …

amazon-web-services boto3 aws-lambda aws-api-gateway

2
推荐指数
1
解决办法
732
查看次数