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

Change image used for test to avoid image name cache preventing proper pull #3378

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.junit.Test;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
import org.testcontainers.utility.DockerImageName;

import java.util.List;
Expand All @@ -16,16 +15,15 @@ public class AmbiguousImagePullTest {
public void testNotUsingParse() {
DockerClient client = DockerClientFactory.instance().client();
List<Image> alpineImages = client.listImagesCmd()
.withImageNameFilter("alpine:latest")
.withImageNameFilter("testcontainers/helloworld:latest")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never use the latest tag of this image anywhere else, so we can safely use it here without worrying about it being recorded in the cache of available images.

.exec();
for (Image alpineImage : alpineImages) {
client.removeImageCmd(alpineImage.getId()).exec();
}

try (
final GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("alpine"))
.withCommand("/bin/sh", "-c", "sleep 0")
.withStartupCheckStrategy(new OneShotStartupCheckStrategy())
final GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("testcontainers/helloworld"))
.withExposedPorts(8080)
) {
container.start();
// do nothing other than start and stop
Expand Down