我无法使用AWS开发工具包的putObject将文件上传到本地堆栈中的假s3。尝试调用putObject时收到未知的主机异常。 SDK正在呼唤my-bucket.localstack:4572,但我的docker contains似乎无法解析请求并引发未知主机异常。是否可以将my-bucket.localstack:4572指向localstack?

version: "3"
services:
  app:
    image: app:latest
    command: run
    networks:
      - mynetwork
    ports:
      - 8000:8080
    environment:
      - AWS_ACCESS_KEY_ID=111
      - AWS_SECRET_ACCESS_KEY=111
      - AWS_REGION=us-east-1
      - spring_profiles_active=local

  localstack:
    image: localstack/localstack
    networks:
      - mynetwork
    ports:
      - "4567-4584:4567-4584"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=sqs,s3

networks:
  mynetwork:
    driver: bridge

最佳答案

配置AWS开发工具包以使用路径样式访问解决了我的问题。

请参阅此Github问题:https://github.com/localstack/localstack/issues/43#issuecomment-308273958

08-28 15:03