Skip to content

[Bug]: Build fails when "version" is omitted from docker-compose.yml #7825

@bernhof

Description

@bernhof

Module

Core

Testcontainers version

1.19.1

Using the latest Testcontainers version?

Yes

Host OS

Alpine Linux v3.18

Host Arch

x86

Docker version

Server Version: 24.0.6

What happened?

We use DockerComposeContainer, and builds fail in our CI environment with the following error:

org.testcontainers.containers.ContainerLaunchException: Container startup failed for image docker/compose:1.29.2

Relevant log output

11:24:41.098 [Test worker] ERROR tc.docker/compose:1.29.2 - Log output from the failed container:
Creating network "pbqs5beuh5ua_default" with the default driver
Pulling <name of image> (<registry url>)...
Head "<manifest url>": denied: access forbidden

Additional Information

Many hours of trial and error revealed the following fix:

Our docker-compose.yml did not contain a "version" element (which is not required by the compose specification). If I add "version: '3'" to my docker-compose.yml file, the build succeeds in the CI environment:

version: '3' # must add this
services:
    ...

After adding the version element, I see the following log message in our CI environment, which seems to be the main difference between the failing and succeeding builds:

o.t.containers.ComposeDelegate - Preemptively checking local images for '<image name>', referenced via a compose file or transitive Dockerfile. If not available, it will be pulled.

If version is ommitted from docker-compose.yml, testcontainers should assume latest compose file version, or at least log a warning that point us in the right direction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions