package org.testcontainers.dockerclient;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.model.Image;
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;

public class AmbiguousImagePullTest {

    @Test(timeout = 30_000)
    public void testNotUsingParse() {
        DockerClient client = DockerClientFactory.instance().client();
        List<Image> alpineImages = client.listImagesCmd()
            .withImageNameFilter("alpine:latest")
            .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())
        ) {
            container.start();
            // do nothing other than start and stop
        }
    }
}

@@ -257,87 +257,8 @@
 er;%0A
-import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;%0A
 impo
@@ -304,16 +304,16 @@
 geName;%0A
+
 %0Aimport 
@@ -597,22 +597,41 @@
 Filter(%22
-alpine
+testcontainers/helloworld
 :latest%22
@@ -890,150 +890,75 @@
 se(%22
-alpine%22))%0A                .withCommand(%22/bin/sh%22, %22-c%22, %22sleep 0%22)%0A                .withStartupCheckStrategy(new OneShotStartupCheckStrategy()
+testcontainers/helloworld%22))%0A                .withExposedPorts(8080
 )%0A  

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