-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add support for specifying Docker image in DockerComposeContainer and ComposeContainer #9871
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
Merged
eddumelendez
merged 18 commits into
testcontainers:main
from
fokion:feat/update-compose-container
Oct 10, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
018f97a
Check the property for compose.container.image in order to get the ap…
fokion 33a0c10
fix the checkstyle issues
fokion f1dca21
apply spotless checks
fokion ed3406a
update the test and the cleanup of container
fokion 11bd114
Update ComposeContainer and DockerComposeContainer to the latest vers…
fokion 4acc8fd
Fix an issue with the TestcontainersConfiguration.getInstance().get…
fokion b15f98e
apply spotless
fokion 75004f6
fix javadoc step
fokion 78c8674
do not update the default image
fokion c87cd9e
Adding javadoc to pass the step
fokion 238dffa
adding more tests to unblock this
fokion 8e0f8a1
adding javadoc
fokion 0342c41
fix tests apply spotless
fokion 5ef8e2a
fixing checkstyle issues
fokion ee13d7d
Polish
eddumelendez fdd303e
Add assumptions
eddumelendez 47304c5
disable tests
eddumelendez 093389b
Fix docker compose image
eddumelendez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core/src/test/java/org/testcontainers/containers/ComposeContainerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package org.testcontainers.containers; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.testcontainers.utility.DockerImageName; | ||
|
|
||
| import java.io.File; | ||
| import java.util.Optional; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class ComposeContainerTest { | ||
|
|
||
| public static final String DOCKER_IMAGE = "docker:25.0.2"; | ||
|
|
||
| private static final String COMPOSE_FILE_PATH = "src/test/resources/v2-compose-test.yml"; | ||
|
|
||
| @Test | ||
| void testWithCustomDockerImage() { | ||
| ComposeContainer composeContainer = new ComposeContainer( | ||
| DockerImageName.parse(DOCKER_IMAGE), | ||
| new File(COMPOSE_FILE_PATH) | ||
| ); | ||
| composeContainer.start(); | ||
| verifyContainerCreation(composeContainer); | ||
| composeContainer.stop(); | ||
| } | ||
|
|
||
| @Test | ||
| void testWithCustomDockerImageAndIdentifier() { | ||
| ComposeContainer composeContainer = new ComposeContainer( | ||
| DockerImageName.parse(DOCKER_IMAGE), | ||
| "myidentifier", | ||
| new File(COMPOSE_FILE_PATH) | ||
| ); | ||
| composeContainer.start(); | ||
| verifyContainerCreation(composeContainer); | ||
| composeContainer.stop(); | ||
| } | ||
|
|
||
| private void verifyContainerCreation(ComposeContainer composeContainer) { | ||
| Optional<ContainerState> redis = composeContainer.getContainerByServiceName("redis"); | ||
| assertThat(redis) | ||
| .hasValueSatisfying(container -> { | ||
| assertThat(container.isRunning()).isTrue(); | ||
| assertThat(container.getContainerInfo().getConfig().getLabels()) | ||
| .containsEntry("com.docker.compose.version", "2.24.5"); | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this setter, localCompose is always true and could be inlined.