Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: pull=true has no effect in Docker Compose Container if version is not set #8109

Open
jholsten opened this issue Jan 13, 2024 · 0 comments
Labels

Comments

@jholsten
Copy link

Module

Core

Testcontainers version

1.19.3

Using the latest Testcontainers version?

Yes

Host OS

Windows

Host Arch

x64

Docker version

Client:
 Cloud integration: v1.0.31
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.18.10
 Git commit:        7155243
 Built:             Thu Jan 19 17:43:10 2023
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.17.1 (101757)
 Engine:
  Version:          20.10.23
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.10
  Git commit:       6051f14
  Built:            Thu Jan 19 17:32:04 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

If pull is set to true in the ComposeContainer/DockerComposeContainer, all images in the docker-compose file should be pulled if they are not available locally. For this purpose, all images returned by parsedComposeFile.getServiceNameToImageNames() are pulled in the ComposeDelegate. However, if the version attribute is not set in the docker-compose file, which is no longer necessary, the map returned by parsedComposeFile.getServiceNameToImageNames() is empty, so no images are pulled.

Cause:
In the ParsedDockerComposeFile, the services are only parsed correctly if the composeFileContent contains the version key. Otherwise, the composeFileContent is set as the serviceMap, which results in the service names being interpreted as service definitions.

Suggested Fix:
Remove else block and limit the upper if block to the validation of the version only.

Relevant log output

No response

Additional Information

Example:
docker-compose.yml:

services:
  api:
    image: $CI_REGISTRY/api:latest
    ports:
      - 8000:8000

State of the variables in ParsedDockerComposeFile:93:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant