testcontainers / testcontainers/testcontainers-java

testcontainers 1.12.2 and up does not replace versions from .env

Open
#2,309 9 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/docker-compose resolution/acknowledged
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Hello,

In a couple of projects we were using test containers version 1.12.1 with local-compose and pull enabled.
I have tried to update to testcontainers 1.12.5 however I have start to some errors on my console.

We are using single file docker-compose.yml version 2 and all image versions inside the compose configuration are coming from .env file
In docker-compose.yml we have mysql image with version placeholder
image: eu-west-1.amazonaws.com/content-delivery/mysql:${mysqlversion}
In .env file we have the version for placeholder
mysqlversion=1.0.0-SNAPSHOT

with this configuration, I start to see the errors below.

ERROR c.g.d.c.async.ResultCallbackTemplate - Error during callback com.github.dockerjava.api.exception.BadRequestException: {"message":"invalid reference format"}
	at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:277)
	at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.lambda$executeAndStream$3(OkHttpInvocationBuilder.java:303)
	at java.lang.Thread.run(Thread.java:748)

WARN  o.t.c.DockerComposeContainer - Failed to pull image 'eu-west-1.amazonaws.com/content-delivery/mysql:${mysqlversion}'. Exception message was {"message":"invalid reference format"}

If I put version instead of the placeholder all works fine.
Before the update, we were using 1.12.1 version and that version does not have any problems with this type of configuration.

So, basically this is an issue with the current version.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at DockerComposeContainer's image-pull handling and reproduce the reported setup with a version placeholder in docker-compose.yml and its value in .env. Compare behavior between testcontainers 1.12.1 and 1.12.5, and consider the issue done when the placeholder resolves to a valid image reference during pulls.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.