7171 */
7272@ Slf4j
7373public class DockerComposeContainer <SELF extends DockerComposeContainer <SELF >> extends FailureDetectingExternalResource implements Startable {
74-
74+ private static final String DEFAULT_DOCKER_COMPOSE_VERSION = "1.29.2" ;
7575 /**
7676 * Random identifier which will become part of spawned containers names, so we can shut them down
7777 */
@@ -81,6 +81,7 @@ public class DockerComposeContainer<SELF extends DockerComposeContainer<SELF>> e
8181 private final Map <String , Integer > scalingPreferences = new HashMap <>();
8282 private DockerClient dockerClient ;
8383 private boolean localCompose ;
84+ private String dockerComposeVersion = DEFAULT_DOCKER_COMPOSE_VERSION ;
8485 private boolean pull = true ;
8586 private boolean build = false ;
8687 private Set <String > options = new HashSet <>();
@@ -195,6 +196,11 @@ private void pullImages() {
195196 });
196197 }
197198
199+ public SELF withDockerComposeVersion (String version ) {
200+ this .dockerComposeVersion = version ;
201+ return self ();
202+ }
203+
198204 public SELF withServices (@ NonNull String ... services ) {
199205 this .services = Arrays .asList (services );
200206 return self ();
@@ -300,7 +306,7 @@ private void runWithCompose(String cmd) {
300306 if (localCompose ) {
301307 dockerCompose = new LocalDockerCompose (composeFiles , project );
302308 } else {
303- dockerCompose = new ContainerisedDockerCompose (composeFiles , project );
309+ dockerCompose = new ContainerisedDockerCompose (composeFiles , project , dockerComposeVersion );
304310 }
305311
306312 dockerCompose
@@ -608,11 +614,11 @@ interface DockerCompose {
608614class ContainerisedDockerCompose extends GenericContainer <ContainerisedDockerCompose > implements DockerCompose {
609615
610616 public static final char UNIX_PATH_SEPERATOR = ':' ;
611- public static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName . parse ( "docker/compose:1.29.2" ) ;
617+ public static final String DEFAULT_IMAGE_NAME = "docker/compose" ;
612618
613- public ContainerisedDockerCompose (List <File > composeFiles , String identifier ) {
619+ public ContainerisedDockerCompose (List <File > composeFiles , String identifier , String dockerComposeVersion ) {
614620
615- super (DEFAULT_IMAGE_NAME );
621+ super (DockerImageName . parse ( DEFAULT_IMAGE_NAME + ":" + dockerComposeVersion ) );
616622 addEnv (ENV_PROJECT_NAME , identifier );
617623
618624 // Map the docker compose file into the container
0 commit comments