小编Tec*_*ash的帖子

运行命令时,本地 Docker Compose 异常退出,代码为 1:up -d

我正在尝试使用创建测试容器DockerComposeContainer

DockerComposeContainer container =
                  new DockerComposeContainer(
                          new File("src/integrationTest/resources/mycompose-file.yml"))
                      .withLocalCompose(true)
                      .withExposedService("mongodb", 27017, Wait.forListeningPort());
              container.start();
              return container;

Run Code Online (Sandbox Code Playgroud)

mycopose-file.yml有以下内容:

version: '3'

services:
  mongodb:
    image: mongo:3.6
    environment:
      MONGO_INITDB_ROOT_USERNAME: uname
      MONGO_INITDB_ROOT_PASSWORD: upass

Run Code Online (Sandbox Code Playgroud)

我的测试依赖项包括: testcontainers-1.12.3.jar

我在应用程序上下文启动期间收到错误: java.lang.IllegalStateException: Failed to load ApplicationContext

根本原因:

Caused by: org.testcontainers.containers.ContainerLaunchException: Local Docker Compose exited abnormally with code 1 whilst running command: up -d
    at org.testcontainers.containers.LocalDockerCompose.invoke(DockerComposeContainer.java:711)
....

Run Code Online (Sandbox Code Playgroud)

containers mongodb docker spring-boot

5
推荐指数
1
解决办法
2320
查看次数

标签 统计

containers ×1

docker ×1

mongodb ×1

spring-boot ×1