@@ -19,9 +19,11 @@ export default class DockerComposeConnection extends ContainerConnection {
19
19
private requireAdditionalDockerComposeFiles : boolean ;
20
20
private projectName : string ;
21
21
private finalComposeFile : string ;
22
+ private useDockerComposeV2 : boolean ;
22
23
23
24
constructor ( ) {
24
25
super ( ) ;
26
+ this . useDockerComposeV2 = tl . getBoolFeatureFlag ( 'USE_DOCKER_COMPOSE_V2_COMPATIBLE_MODE' ) ;
25
27
this . setDockerComposePath ( ) ;
26
28
this . dockerComposeFile = DockerComposeUtils . findDockerFile ( tl . getInput ( "dockerComposeFile" , true ) , tl . getInput ( "cwd" ) ) ;
27
29
if ( ! this . dockerComposeFile ) {
@@ -91,6 +93,12 @@ export default class DockerComposeConnection extends ContainerConnection {
91
93
92
94
public createComposeCommand ( ) : tr . ToolRunner {
93
95
var command = tl . tool ( this . dockerComposePath ) ;
96
+
97
+ if ( this . useDockerComposeV2 ) {
98
+ command . arg ( "compose" ) ;
99
+ command . arg ( "--compatibility" ) ;
100
+ }
101
+
94
102
command . arg ( [ "-f" , this . dockerComposeFile ] ) ;
95
103
var basePath = path . dirname ( this . dockerComposeFile ) ;
96
104
this . additionalDockerComposeFiles . forEach ( file => {
@@ -177,8 +185,13 @@ export default class DockerComposeConnection extends ContainerConnection {
177
185
//Priority to docker-compose path provided by user
178
186
this . dockerComposePath = tl . getInput ( 'dockerComposePath' ) ;
179
187
if ( ! this . dockerComposePath ) {
180
- //If not use the docker-compose avilable on agent
181
- this . dockerComposePath = tl . which ( "docker-compose" ) ;
188
+ // If not use the docker-compose avilable on agent
189
+ if ( this . useDockerComposeV2 ) {
190
+ this . dockerComposePath = tl . which ( "docker" ) ;
191
+ } else {
192
+ this . dockerComposePath = tl . which ( "docker-compose" ) ;
193
+ }
194
+
182
195
if ( ! this . dockerComposePath ) {
183
196
throw new Error ( "Docker Compose was not found. You can provide the path to docker-compose via 'dockerComposePath' " ) ;
184
197
}
0 commit comments