Local Docker Compose exited abnormally with code 1 whilst running command: up -d

Viewed 1196

I am trying to create test container with DockerComposeContainer.

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

mycopose-file.yml has following:

version: '3'

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

My test dependency include: testcontainers-1.12.3.jar

I am getting error during application context startup: java.lang.IllegalStateException: Failed to load ApplicationContext

with root cause:

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)
....

1 Answers

In my case I got this error because network in docker had exhausted. Given docker has limited network that we can have. We have to do the cleanup, for that I ran command:

docker network prune

this fixed my problem

Related