testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.97k stars 1.64k forks source link

DockerComposeContainer integration with Testcontainer throws Container startup failed error #5477

Open PrashantNavkudkar opened 2 years ago

PrashantNavkudkar commented 2 years ago

I have code setup for launching Selenium GRID with the help of Testcontainer. When I run it on local system it works fine but when I do the same on bitbucket pipeline it failed to start container.

Here I used the code to launch Selenium GRID setup:

DockerComposeContainer environment = new DockerComposeContainer(new File("docker-compose-v3-scale-chrome-no-port.yml"))
                .withExposedService("hub", 4444, Wait.forListeningPort());
                environment.start();

Here is my bitbucket pipeline file:

image: maven:3.6.3
pipelines:
  default:
      - step:
          size: 2x # Double resources available for this step.
          caches:
            - maven                     
          name: Build and Test
          #runs-on: 
            #- 'self.hosted'
            #- 'apirunner1'
          script:
            - export TESTCONTAINERS_RYUK_DISABLED=true
            - mvn clean test -DClassesToRun="LoginSanitySuite_New~LoginSanitySuite" -DCountriesValue="US~CA" -DBROWSER="CHR_GRID"  -DThreadCount="5" -DEnvironment="PROD"
            #- mvn clean test
          services:
            - docker 
          artifacts:
            - ExtentReports/index.html
            - process-logs.txt
            - memory-logs.txt
            - docker-event-logs.txt

definitions:
  services:
    docker:
      memory: 3072

=====================================

Here is my docker compose file

version: "2"
services:

  hub:
    image: selenium/hub:3.141.59
    ports:
      - "4443:4444"

    environment:
      GRID_MAX_SESSION: 28
      GRID_BROWSER_TIMEOUT: 3000
      GRID_TIMEOUT: 3000

  chrome1:
    image: selenium/node-chrome-debug:3.141.59
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444
      NODE_MAX_SESSION: 3
      NODE_MAX_INSTANCES: 3
    links:
      - hub

  chrome2:
    image: selenium/node-chrome-debug:3.141.59
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444
      NODE_MAX_SESSION: 3
      NODE_MAX_INSTANCES: 3
    links:
      - hub 

===================== Adding docker error log for reference ===================

[WARN  tini (8)] Tini is not running as PID 1 and isn't registered as a child subreaper.
Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
To fix the problem, use the -s option or set the environment variable TINI_SUBREAPER to register Tini as a child subreaper, or run Tini as PID 1.
time="2022-06-07T13:01:15.955207346Z" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
time="2022-06-07T13:01:15.955824052Z" level=warning msg="Binding to IP address without --tlsverify is insecure and gives root access on this machine to everyone who has access to your network." host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:15.955854686Z" level=warning msg="Binding to an IP address, even on localhost, can also give access to scripts run in a browser. Be safe out there!" host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:16.956791997Z" level=warning msg="Binding to an IP address without --tlsverify is deprecated. Startup is intentionally being slowed down to show this message" host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:16.956837066Z" level=warning msg="Please consider generating tls certificates with client validation to prevent exposing unauthenticated root access to your network" host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:16.956851394Z" level=warning msg="You can override this by explicitly specifying '--tls=false' or '--tlsverify=false'" host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:16.956860569Z" level=warning msg="Support for listening on TCP without authentication or explicit intent to run without authentication will be removed in the next release" host="tcp://0.0.0.0:2375"
time="2022-06-07T13:01:32Z" level=warning msg="deprecated version : `1`, please switch to version `2`"
time="2022-06-07T13:01:32.087434258Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.devmapper" error="devmapper not configured"
time="2022-06-07T13:01:32.088168834Z" level=warning msg="could not use snapshotter devmapper in metadata plugin" error="devmapper not configured"
time="2022-06-07T13:01:32.092830542Z" level=warning msg="failed to load plugin io.containerd.internal.v1.opt" error="mkdir /opt/containerd: read-only file system"
time="2022-06-07T13:01:32.092941675Z" level=error msg="failed to initialize a tracing processor \"otlp\"" error="no OpenTelemetry endpoint: skip plugin"
time="2022-06-07T13:01:32.186431041Z" level=warning msg="Your kernel does not support CPU realtime scheduler"
time="2022-06-07T13:01:32.186477358Z" level=warning msg="Your kernel does not support cgroup blkio weight"
time="2022-06-07T13:01:32.186485322Z" level=warning msg="Your kernel does not support cgroup blkio weight_device"
time="2022-06-07T13:02:28Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/info
time="2022-06-07T13:02:29Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/version
time="2022-06-07T13:02:29Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/images/json
time="2022-06-07T13:02:29Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/selenium%2Fhub:3.141.59/json"
time="2022-06-07T13:02:29.233108463Z" level=error msg="Handler for GET /v1.32/images/selenium%2Fhub:3.141.59/json returned error: no such image: selenium/hub:3.141.59: No such image: selenium/hub:3.141.59"
time="2022-06-07T13:02:29Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/create?fromImage=selenium%2Fhub&tag=3.141.59"
time="2022-06-07T13:02:47Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/selenium%2Fhub:3.141.59/json"
time="2022-06-07T13:02:47Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/selenium%2Fnode-chrome-debug:3.141.59/json"
time="2022-06-07T13:02:47.282486064Z" level=error msg="Handler for GET /v1.32/images/selenium%2Fnode-chrome-debug:3.141.59/json returned error: no such image: selenium/node-chrome-debug:3.141.59: No such image: selenium/node-chrome-debug:3.141.59"
time="2022-06-07T13:02:47Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/create?fromImage=selenium%2Fnode-chrome-debug&tag=3.141.59"
time="2022-06-07T13:03:31Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/selenium%2Fnode-chrome-debug:3.141.59/json"
time="2022-06-07T13:03:31Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/docker%2Fcompose:1.29.2/json"
time="2022-06-07T13:03:31.170263975Z" level=error msg="Handler for GET /v1.32/images/docker%2Fcompose:1.29.2/json returned error: no such image: docker/compose:1.29.2: No such image: docker/compose:1.29.2"
time="2022-06-07T13:03:31Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/create?fromImage=docker%2Fcompose&tag=1.29.2"
time="2022-06-07T13:03:36Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/docker%2Fcompose:1.29.2/json"
time="2022-06-07T13:03:36Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/alpine:3.14/json"
time="2022-06-07T13:03:36.861680333Z" level=error msg="Handler for GET /v1.32/images/alpine:3.14/json returned error: no such image: alpine:3.14: No such image: alpine:3.14"
time="2022-06-07T13:03:36Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/create?fromImage=alpine&tag=3.14"
time="2022-06-07T13:03:38Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/images/alpine:3.14/json"
time="2022-06-07T13:03:38Z" level=info msg="Container create request." ArgsEscaped=false AttachStderr=false AttachStdin=false AttachStdout=false ExposedPorts="map[]" Healthcheck="<nil>" Labels="map[org.testcontainers:true org.testcontainers.sessionId:04dbde20-21a0-48c2-aed5-7cb3b50092ad]" MacAddress= NetworkDisabled=false OnBuild="[]" OpenStdin=false StdinOnce=false StopSignal= StopTimeout="<nil>" Tty=false plugin=pipelines
time="2022-06-07T13:03:38Z" level=info msg="Container create request." AutoRemove=false BlkioDeviceReadBps="[]" BlkioDeviceReadIOps="[]" BlkioDeviceWriteBps="[]" BlkioDeviceWriteIOps="[]" BlkioWeight=0 BlkioWeightDevice="[]" CPUCount=0 CPUPercent=0 CPUPeriod=0 CPUQuota=0 CPURealtimePeriod=0 CPURealtimeRuntime=0 CPUShares=0 CapAdd="[]" CapDrop="[]" Cgroup= CgroupParent= ConsoleSize="[0 0]" ContainerIDFile= CpusetCpus= CpusetMems= DNS="[]" DNSOptions="[]" DNSSearch="[]" DeviceCgroupRules="[]" Devices="[]" ExtraHosts="[]" GroupAdd="[]" IOMaximumBandwidth=0 IOMaximumIOps=0 Init="<nil>" IpcMode= Isolations= KernelMemory=0 Links="[]" LogConfig="{ map[]}" MaskedPaths="[]" Memory=0 MemoryReservation=0 MemorySwap=0 MemorySwappiness="<nil>" Mounts="[]" NanoCPUs=0 NetworkMode=default OomKillDisable="<nil>" OomScoreAdj=0 PidMode= PidsLimit="<nil>" PortBindings="map[]" Privileged=false PublishAllPorts=false ReadOnlyPaths="[]" RestartPolicy="{ 0}" Runtime= SecurityOpt="[]" ShmSize=0 StorageOpt="map[]" Sysctls="map[]" Ulimits="[]" UsernsMode= VolumeDriver= VolumesFrom="[]" plugin=pipelines
time="2022-06-07T13:03:38Z" level=info msg="Pipelines plugin request authorization." allowed=false method=POST plugin=pipelines uri=/v1.32/containers/create
time="2022-06-07T13:03:38.403293133Z" level=error msg="AuthZRequest for POST /v1.32/containers/create returned error: authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"
time="2022-06-07T13:03:38Z" level=info msg="Container create request." ArgsEscaped=false AttachStderr=false AttachStdin=false AttachStdout=false ExposedPorts="map[]" Healthcheck="<nil>" Labels="map[org.testcontainers:true org.testcontainers.sessionId:04dbde20-21a0-48c2-aed5-7cb3b50092ad]" MacAddress= NetworkDisabled=false OnBuild="[]" OpenStdin=false StdinOnce=false StopSignal= StopTimeout="<nil>" Tty=false plugin=pipelines
time="2022-06-07T13:03:38Z" level=info msg="Container create request." AutoRemove=false BlkioDeviceReadBps="[]" BlkioDeviceReadIOps="[]" BlkioDeviceWriteBps="[]" BlkioDeviceWriteIOps="[]" BlkioWeight=0 BlkioWeightDevice="[]" CPUCount=0 CPUPercent=0 CPUPeriod=0 CPUQuota=0 CPURealtimePeriod=0 CPURealtimeRuntime=0 CPUShares=0 CapAdd="[]" CapDrop="[]" Cgroup= CgroupParent= ConsoleSize="[0 0]" ContainerIDFile= CpusetCpus= CpusetMems= DNS="[]" DNSOptions="[]" DNSSearch="[]" DeviceCgroupRules="[]" Devices="[]" ExtraHosts="[]" GroupAdd="[]" IOMaximumBandwidth=0 IOMaximumIOps=0 Init="<nil>" IpcMode= Isolations= KernelMemory=0 Links="[]" LogConfig="{ map[]}" MaskedPaths="[]" Memory=0 MemoryReservation=0 MemorySwap=0 MemorySwappiness="<nil>" Mounts="[]" NanoCPUs=0 NetworkMode=default OomKillDisable="<nil>" OomScoreAdj=0 PidMode= PidsLimit="<nil>" PortBindings="map[]" Privileged=false PublishAllPorts=false ReadOnlyPaths="[]" RestartPolicy="{ 0}" Runtime= SecurityOpt="[]" ShmSize=0 StorageOpt="map[]" Sysctls="map[]" Ulimits="[]" UsernsMode= VolumeDriver= VolumesFrom="[]" plugin=pipelines
time="2022-06-07T13:03:38Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri=/v1.32/containers/create
time="2022-06-07T13:03:38Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/start
time="2022-06-07T13:03:38.741176721Z" level=info msg="loading plugin \"io.containerd.event.v1.publisher\"..." runtime=io.containerd.runc.v2 type=io.containerd.event.v1
time="2022-06-07T13:03:38.741273225Z" level=info msg="loading plugin \"io.containerd.internal.v1.shutdown\"..." runtime=io.containerd.runc.v2 type=io.containerd.internal.v1
time="2022-06-07T13:03:38.741291791Z" level=info msg="loading plugin \"io.containerd.ttrpc.v1.task\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1
time="2022-06-07T13:03:38.753802513Z" level=info msg="starting signal loop" namespace=moby path=/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346 pid=643 runtime=io.containerd.runc.v2
time="2022-06-07T13:03:39Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:40Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:41.865694516Z" level=warning msg="cleaning up after shim disconnected" id=cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346 namespace=moby
time="2022-06-07T13:03:41.941645427Z" level=warning msg="cleanup warnings time=\"2022-06-07T13:03:41Z\" level=info msg=\"starting signal loop\" namespace=moby pid=705 runtime=io.containerd.runc.v2\n"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/json
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/logs?stdout=true&stderr=true&since=0"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346/logs?stdout=true&stderr=true&since=0"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/containers/json?all=true&filters=%7B%22label%22%3A%5B%22org.testcontainers%3Dtrue%22%2C%22org.testcontainers.sessionId%3D04dbde20-21a0-48c2-aed5-7cb3b50092ad%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=DELETE plugin=pipelines uri="/v1.32/containers/cb244da326dccd9402ed0c409be08b97f5f3b3e337b01cc194f5ae96216fb346?v=true&force=true"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/v1.32/containers/json?all=true&filters=%7B%22label%22%3A%5B%22com.docker.compose.project%3Dnx57zmchnxzx%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/networks/prune?filters=%7B%22label%22%3A%5B%22org.testcontainers%3Dtrue%22%2C%22org.testcontainers.sessionId%3D04dbde20-21a0-48c2-aed5-7cb3b50092ad%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/networks/prune?filters=%7B%22label%22%3A%5B%22com.docker.compose.project%3Dnx57zmchnxzx%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/volumes/prune?filters=%7B%22label%22%3A%5B%22org.testcontainers%3Dtrue%22%2C%22org.testcontainers.sessionId%3D04dbde20-21a0-48c2-aed5-7cb3b50092ad%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/volumes/prune?filters=%7B%22label%22%3A%5B%22com.docker.compose.project%3Dnx57zmchnxzx%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/prune?filters=%7B%22label%22%3A%5B%22org.testcontainers%3Dtrue%22%2C%22org.testcontainers.sessionId%3D04dbde20-21a0-48c2-aed5-7cb3b50092ad%22%5D%7D"
time="2022-06-07T13:03:42Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/v1.32/images/prune?filters=%7B%22label%22%3A%5B%22com.docker.compose.project%3Dnx57zmchnxzx%22%5D%7D"
eddumelendez commented 2 years ago

@PrashantNavkudkar which testcontainers version are you using? it is the latest 1.17.3? Looking at the logs looks similar to #700

ocapo commented 1 year ago

I'm using testcontainers 1.17.6 and I have the same error. In the same project I have a standard TestContainer and it works fine, so I believe that the problem is only with the DockerComposeContainer.

Here the init code:

val container = DockerComposeContainer(File("unleash-docker-compose.yml"))
    .withExposedService("unleash_1", 4242, Wait.forListeningPort())
    .waitingFor("postgres_1", Wait.forListeningPort())

unleash-docker-compose.yml

version: "3.9"

services:
    unleash:
        image: "unleashorg/unleash-server:4.20.2"
        environment:
            DATABASE_URL: "postgres://postgres:unleash@postgres/postgres"
            DATABASE_SSL: "false"
            INIT_CLIENT_API_TOKENS: "default:development.unleash-insecure-api-token"
            INIT_ADMIN_API_TOKENS: "*:*.unleash-insecure-api-token"
    postgres:
        image: "postgres:15.1"
        environment:
            POSTGRES_DB: "db"
            POSTGRES_HOST_AUTH_METHOD: "trust"

My stacktrace

[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/assertj/assertj-parent-pom/2.2.14/assertj-parent-pom-2.2.14.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/assertj/assertj-parent-pom/2.2.14/assertj-parent-pom-2.2.14.pom (25 kB at 846 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/junit-bom/5.8.0/junit-bom-5.8.0.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/junit-bom/5.8.0/junit-bom-5.8.0.pom (5.6 kB at 245 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/3.0.0-M6/common-java5-3.0.0-M6.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.2/junit-platform-launcher-1.3.2.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.2/junit-platform-engine-1.3.2.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.2/junit-platform-commons-1.3.2.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/3.0.0-M6/common-java5-3.0.0-M6.jar (17 kB at 2.5 MB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.2/junit-platform-commons-1.3.2.jar (78 kB at 13 MB/s)
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.2/junit-platform-launcher-1.3.2.jar (95 kB at 9.5 MB/s)
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar (2.2 kB at 270 kB/s)
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.2/junit-platform-engine-1.3.2.jar (138 kB at 17 MB/s)
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar (7.1 kB at 890 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.jar (159 kB at 12 MB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.pom (3.0 kB at 504 kB/s)
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.idealista.yaencontre.testcontainers.UnleashContainerTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 33.485 s <<< FAILURE! - in com.idealista.yaencontre.testcontainers.UnleashContainerTest
[ERROR] com.idealista.yaencontre.testcontainers.UnleashContainerTest.test unleash container  Time elapsed: 32.687 s  <<< ERROR!
org.testcontainers.containers.ContainerLaunchException: Container startup failed
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at org.testcontainers.containers.ContainerisedDockerCompose.invoke(DockerComposeContainer.java:710)
    at org.testcontainers.containers.DockerComposeContainer.runWithCompose(DockerComposeContainer.java:337)
    at org.testcontainers.containers.DockerComposeContainer.createServices(DockerComposeContainer.java:258)
    at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:189)
    at com.idealista.yaencontre.testcontainers.UnleashContainerTest.start unleash container(UnleashContainerTest.kt:23)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeEachMethod(TimeoutExtension.java:76)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:506)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$21(ClassBasedTestDescriptor.java:491)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachMethods$3(TestMethodTestDescriptor.java:171)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:168)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:55)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:223)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:175)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:139)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:456)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:169)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:595)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:581)
    Suppressed: org.testcontainers.containers.ContainerLaunchException: Container startup failed
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at org.testcontainers.containers.ContainerisedDockerCompose.invoke(DockerComposeContainer.java:710)
        at org.testcontainers.containers.DockerComposeContainer.runWithCompose(DockerComposeContainer.java:337)
        at org.testcontainers.containers.DockerComposeContainer.stop(DockerComposeContainer.java:375)
        at com.idealista.yaencontre.testcontainers.UnleashContainerTest.stop unleash container(UnleashContainerTest.kt:28)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
        at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
        at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
        at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
        at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
        at org.junit.jupiter.engine.extension.TimeoutExtension.interceptAfterEachMethod(TimeoutExtension.java:108)
        at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
        at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
        at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
        at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
        at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
        at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
        at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
        at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:506)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeAfterEachMethodAdapter$22(ClassBasedTestDescriptor.java:496)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachMethods$10(TestMethodTestDescriptor.java:240)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachMethods(TestMethodTestDescriptor.java:238)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:139)
        ... 48 more
    Caused by: 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:334)
        ... 81 more
    Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:542)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        ... 82 more
    Caused by: java.lang.IllegalStateException: Container did not start correctly.
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:480)
        ... 84 more
Caused by: 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:334)
    ... 80 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:542)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    ... 81 more
Caused by: java.lang.IllegalStateException: Container did not start correctly.
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:480)
    ... 83 more

Thanks!

RobSis commented 1 year ago

I have the similar issue, but only when I'm calling containter.stop(). Start works fine. Kinda confusing why the stop method produces "Container did not start correctly" messages...

hebertthome commented 5 months ago

I'm having the same problem as the colleagues above when I try to run the test on the Bitbucket pipeline. I'm using testcontainers 1.19.7.

I'm starting the container when I initialize the test environment...

public class DockerComposeContainerSingletron {

    public static DockerComposeContainer<?> environment;

    @SuppressWarnings("resource")
    public static synchronized DockerComposeContainer<?> getInstance() {

        if (environment == null) {
            environment = new DockerComposeContainer<>(
                    new File("src/test/resources/docker/docker-compose-integration.yml"))
                    .withExposedService("wiremock-integration", 8080,
                            Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(60)))
                    .withExposedService("postgres-integration", 5432,
                            Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(60)));
            environment.start();
        }

        return environment;
    }

}
   @DynamicPropertySource
    public static void allProperties(DynamicPropertyRegistry registry) {

        DockerComposeContainer<?> environment = DockerComposeContainerSingletron.getInstance();

        registry.add("wiremock-host", () -> environment.getServiceHost("wiremock-integration", 8080));
        registry.add("wiremock-port", () -> environment.getServicePort("wiremock-integration", 8080));

        registry.add("postgres-host", () -> environment.getServiceHost("postgres-integration", 5432));
        registry.add("postgres-port", () -> environment.getServicePort("postgres-integration", 5432));

    }

Compose file...

version: '3.8'

services:

  postgres-integration:
    image: postgres:12.8-alpine
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

  wiremock-integration:
    image: "wiremock/wiremock:3.3.1" 

And received this traces..

java.lang.IllegalStateException: Container did not start correctly.
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:495)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:354)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:344)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:330)
    at org.testcontainers.containers.ContainerisedDockerCompose.invoke(ContainerisedDockerCompose.java:64)
    at org.testcontainers.containers.ComposeDelegate.runWithCompose(ComposeDelegate.java:254)
    at org.testcontainers.containers.ComposeDelegate.createServices(ComposeDelegate.java:163)
    at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:137)
    at integration.config.DockerComposeContainerSingletron.getInstance(DockerComposeContainerSingletron.java:29)
    at integration.config.BaseIntegration.allProperties(BaseIntegration.java:49)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
    at org.springframework.test.context.support.DynamicPropertiesContextCustomizer.lambda$buildDynamicPropertiesMap$3(DynamicPropertiesContextCustomizer.java:84)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.test.context.support.DynamicPropertiesContextCustomizer.buildDynamicPropertiesMap(DynamicPropertiesContextCustomizer.java:82)
    at org.springframework.test.context.support.DynamicPropertiesContextCustomizer.customizeContext(DynamicPropertiesContextCustomizer.java:72)
    at org.springframework.boot.test.context.SpringBootContextLoader$ContextCustomizerAdapter.initialize(SpringBootContextLoader.java:326)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:607)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272)
    at java.base/java.util.Optional.orElseGet(Optional.java:369)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271)
    at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$before$2(ClassBasedTestDescriptor.java:197)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:196)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:80)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)

and

{"@timestamp":"2024-04-03T02:41:39.468Z","log.level":"ERROR","message":"Log output from the failed container:
[10] Failed to execute script docker-compose
Traceback (most recent call last):
  File \"urllib3/connectionpool.py\", line 677, in urlopen
  File \"urllib3/connectionpool.py\", line 392, in _make_request
  File \"http/client.py\", line 1277, in request
  File \"http/client.py\", line 1323, in _send_request
  File \"http/client.py\", line 1272, in endheaders
  File \"http/client.py\", line 1032, in _send_output
  File \"http/client.py\", line 972, in send
  File \"docker/transport/unixconn.py\", line 43, in connect
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"requests/adapters.py\", line 449, in send
  File \"urllib3/connectionpool.py\", line 727, in urlopen
  File \"urllib3/util/retry.py\", line 410, in increment
  File \"urllib3/packages/six.py\", line 734, in reraise
  File \"urllib3/connectionpool.py\", line 677, in urlopen
  File \"urllib3/connectionpool.py\", line 392, in _make_request
  File \"http/client.py\", line 1277, in request
  File \"http/client.py\", line 1323, in _send_request
  File \"http/client.py\", line 1272, in endheaders
  File \"http/client.py\", line 1032, in _send_output
  File \"http/client.py\", line 972, in send
  File \"docker/transport/unixconn.py\", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"docker/api/client.py\", line 214, in _retrieve_server_version
  File \"docker/api/daemon.py\", line 181, in version
  File \"docker/utils/decorators.py\", line 46, in inner
  File \"docker/api/client.py\", line 237, in _get
  File \"requests/sessions.py\", line 543, in get
  File \"requests/sessions.py\", line 530, in request
  File \"requests/sessions.py\", line 643, in send
  File \"requests/adapters.py\", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"docker-compose\", line 3, in <module>
  File \"compose/cli/main.py\", line 81, in main
  File \"compose/cli/main.py\", line 200, in perform_command
  File \"compose/cli/command.py\", line 70, in project_from_options
  File \"compose/cli/command.py\", line 153, in get_project
  File \"compose/cli/docker_client.py\", line 43, in get_client
  File \"compose/cli/docker_client.py\", line 170, in docker_client
  File \"docker/api/client.py\", line 197, in __init__
  File \"docker/api/client.py\", line 222, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))
","ecs.version": "1.2.0","service.name":"xxxx","event.dataset":"xxxx","process.thread.name":"main","log.logger":"tc.docker/compose:1.29.2"}
miteshaghera commented 1 month ago

I have same issue with 1.19.8 version.

After enabling debug log I found following...

2024-07-26T15:48:51,064 DEBUG [main]  o.t.s.c.g.d.c.c.AbstrDockerCmd.exec:32 Cmd: alpine:3.17
2024-07-26T15:48:51,067 DEBUG [main]  o.t.u.RegistryAuthLocator.lookupAuthConfig:121 Looking up auth config for image: alpine:3.17 at registry: https://index.docker.io/v1/
2024-07-26T15:48:51,067 DEBUG [main]  o.t.u.RegistryAuthLocator.lookupAuthConfig:132 No matching Auth Configs - falling back to defaultAuthConfig [null]
2024-07-26T15:48:51,068 DEBUG [main]  o.t.d.AuthDelegatingDockerClientConfig.effectiveAuthConfig:47 Effective auth config [null]
2024-07-26T15:48:51,069 DEBUG [main]  o.t.u.MountableFile.extractClassPathResourceToTempLocation:248 Copying classpath resource(s) from jar:file:/root/.m2/repository/org/testcontainers/testcontainers/1.19.8/testcontainers-1.19.8.jar!/org/testcontainers/utility/ResourceReaper.class to /tmp/.testcontainers-tmp-13038302771217870581 to permit Docker to bind
2024-07-26T15:48:51,069 DEBUG [main]  o.t.u.MountableFile.copyFromJarToLocation:294 Copying resource org/testcontainers/utility/ResourceReaper.class from JAR file /root/.m2/repository/org/testcontainers/testcontainers/1.19.8/testcontainers-1.19.8.jar
2024-07-26T15:48:51,107 DEBUG [main]  o.t.s.c.g.d.c.c.AbstrDockerCmd.exec:32 Cmd: org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl@10370297[aliases=,argsEscaped=,attachStderr=,attachStdin=,attachStdout=,authConfig=,cmd=,domainName=,entrypoint=,env=,exposedPorts=ExposedPorts(exposedPorts=[]),healthcheck=,hostConfig=HostConfig(binds=[/tmp/.testcontainers-tmp-13038302771217870581:/dummy:ro], blkioWeight=null, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=null, capAdd=null, capDrop=null, containerIDFile=null, cpuPeriod=null, cpuRealtimePeriod=null, cpuRealtimeRuntime=null, cpuShares=null, cpuQuota=null, cpusetCpus=null, cpusetMems=null, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=null, cgroup=null, links=[], logConfig=LogConfig(type=null, config=null), lxcConf=null, memory=null, memorySwap=null, memoryReservation=null, kernelMemory=null, networkMode=null, oomKillDisable=null, init=null, autoRemove=null, oomScoreAdj=null, portBindings=null, privileged=null, publishAllPorts=null, readonlyRootfs=null, restartPolicy=null, ulimits=null, cpuCount=null, cpuPercent=null, ioMaximumIOps=null, ioMaximumBandwidth=null, volumesFrom=null, mounts=null, pidMode=null, isolation=null, securityOpts=null, storageOpt=null, cgroupParent=null, volumeDriver=null, shmSize=null, pidsLimit=null, runtime=null, tmpFs=null, utSMode=null, usernsMode=null, sysctls=null, consoleSize=null, cgroupnsMode=null),hostName=,image=alpine:3.17,ipv4Address=,ipv6Address=,labels={org.testcontainers=true, org.testcontainers.lang=java, org.testcontainers.version=1.19.8, org.testcontainers.sessionId=5c658723-0dbb-4c14-bb3e-a8ecf83f2e5e},macAddress=,name=,networkDisabled=,networkingConfig=,onBuild=,platform=,portSpecs=,shell=,stdInOnce=,stdinOpen=,stopSignal=,stopTimeout=,tty=,user=,volumes=Volumes(volumes=[]),workingDir=]
2024-07-26T15:48:51,159 DEBUG [main]  o.t.DockerClientFactory.checkMountableFile:298 Failure while checking for mountable file support
com.github.dockerjava.api.exception.DockerException: Status 403: {"message":"authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories"}

    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:249)
    at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:124)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:37)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
    at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33)
    at org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:608)
    at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:351)
    at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:338)
    at org.testcontainers.DockerClientFactory.checkMountableFile(DockerClientFactory.java:280)
    at org.testcontainers.DockerClientFactory.isFileMountingSupported(DockerClientFactory.java:97)
    at org.testcontainers.containers.ContainerDef.applyTo(ContainerDef.java:117)
    at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:783)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:389)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:354)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:344)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:330)
    at org.testcontainers.containers.ContainerisedDockerCompose.invoke(ContainerisedDockerCompose.java:64)
    at org.testcontainers.containers.ComposeDelegate.runWithCompose(ComposeDelegate.java:254)
    at org.testcontainers.containers.ComposeDelegate.createServices(ComposeDelegate.java:163)
    at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:137)

Look like this volume /tmp/.testcontainers-tmp-13038302771217870581:/dummy:ro mount is restricted in bitbucket pipeline.