【问题标题】:moto-server docker image with test container for AWS EC2带有 AWS EC2 测试容器的 moto-server docker 映像
【发布时间】:2021-10-30 16:51:19
【问题描述】:

Moto 是模拟 AWS 服务:https://github.com/spulec/moto

当我尝试测试 aws ec2 服务时,moto-server docker image 的 GenericContainer 失败。

代码:

 Map<String, String> map = new HashMap<>();
            map.put("AWS_DEFAULT_REGION", "us-east-1");
            map.put("AWS_ACCESS_KEY_ID", "YOUR_AWS_ACCESS_KEY");
            map.put("AWS_SECRET_ACCESS_KEY", "YOUR_AWS_SECRET_KEY");
            map.put("service_name", "s3");
            map.put("region_name", "us-east-1");
            map.put("endpoint_url", "http://localhost:5000");

            GenericContainer genericContainer = new GenericContainer<>(DockerImageName.parse(
                "motoserver/moto"))
                .withEnv(map)
                .withEnv("moto_server","ec2")
                .withNetwork(tcNetwork)
                .withExposedPorts(3000);
            genericContainer.start();

谁能帮我解决 moto-server 所需的参数

日志:

Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:330)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:311)

【问题讨论】:

    标签: java docker amazon-ec2 testcontainers moto


    【解决方案1】:

    我找到了不同方法的解决方案:

     GenericContainer genericContainer = new GenericContainer(
            DockerImageName.parse("motoserver/moto"))
            .withCommand("ec2").withEnv("AWS_SECRET_ACCESS_KEY", "YOUR_AWS_SECRET_KEY")
            .withEnv("AWS_ACCESS_KEY_ID", "YOUR_AWS_ACCESS_KEY")
            .withEnv("AWS_DEFAULT_REGION", "us-east-1")
                .withEnv("port","3000");
    

    // .withExposedPorts(3000); genericContainer.start();

    【讨论】:

      猜你喜欢
      • 2021-09-06
      • 1970-01-01
      • 2020-01-13
      • 1970-01-01
      • 2018-07-06
      • 2017-12-04
      • 2020-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多