Skip to content

[Bug]: Container startup failed for image alpine/socat:1.7.4.3-r0 when using Nginx in Docker Compose #7644

@jlengrand

Description

@jlengrand

Module

Core

Testcontainers version

1.19.1

Using the latest Testcontainers version?

Yes

Host OS

MacOS

Host Arch

ARM

Docker version

Docker version 24.0.6, build ed223bc

What happened?

When using a Docker Compose image with a NGinx container, the image fails to start. Restarting the Docker engine will work once. Removing the NGinx service makes everything work fine.

version: '3'
  postgrest-db:
    image: postgres:16-alpine
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - DB_SCHEMA=${DB_SCHEMA}
    volumes:
      - "./initdb:/docker-entrypoint-initdb.d"
    networks:
      - postgrest-backend
    restart: always
  postgrest:
    image: postgrest/postgrest:latest
    ports:
      - "3000:3000"
    # https://postgrest.org/en/latest/configuration.html#environment-variables
    environment:
      - PGRST_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgrest-db:5432/${POSTGRES_DB}
      - PGRST_DB_SCHEMA=${DB_SCHEMA}
      - PGRST_DB_ANON_ROLE=${DB_ANON_ROLE}
    networks:
      - postgrest-backend
    restart: always
  nginx:
    image: nginx:alpine
    restart: always
    tty: true
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - "80:80"
      - "443:443"
    networks:
      - postgrest-backend

networks:
  postgrest-backend:
    driver: bridge

The java snippet is

@Testcontainers
class MainKtTest {

    @Container
    var environment: DockerComposeContainer<*> =
        DockerComposeContainer(File("src/test/resources/docker-compose.yml"))
            .withExposedService("postgrest-db", 5432)
            .withExposedService("postgrest", 3000)
            .withExposedService("nginx", 80)
            .waitingFor("nginx", Wait.forHttp("/").forStatusCode(200).withStartupTimeout(Duration.ofSeconds(15)))
...
}

Relevant log output

org.testcontainers.containers.ContainerLaunchException: Container startup failed for image alpine/socat:1.7.4.3-r0
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:359)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:334)
	at org.testcontainers.containers.ComposeDelegate.startAmbassadorContainer(ComposeDelegate.java:276)
	at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:145)
	at org.testcontainers.junit.jupiter.TestcontainersExtension$StoreAdapter.start(TestcontainersExtension.java:280)
...
Caused by: org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container 3gcmphvfu3va_nginx_1 as it is not running
	at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:850)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:389)
	... 89 more


Retry limit hit with exception
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:344)

Additional Information

Using docker compose straight starts all services without issues, consistently. Tried changing the pinned version of nginx, with no success either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions