15
15
*/
16
16
package org .springframework .cloud .dataflow .common .test .docker .compose .execution ;
17
17
18
+ import java .io .File ;
18
19
import java .io .IOException ;
19
20
import java .util .ArrayList ;
20
21
import java .util .Arrays ;
@@ -34,7 +35,9 @@ public class DockerComposeExecutable implements Executable {
34
35
private static final DockerCommandLocations DOCKER_COMPOSE_LOCATIONS = new DockerCommandLocations (
35
36
System .getenv ("DOCKER_COMPOSE_LOCATION" ),
36
37
"/usr/local/bin/docker-compose" ,
37
- "/usr/bin/docker-compose"
38
+ "/usr/bin/docker-compose" ,
39
+ "/usr/local/bin/docker" ,
40
+ "/usr/bin/docker"
38
41
);
39
42
40
43
private static String defaultDockerComposePath () {
@@ -52,13 +55,18 @@ static Version version() throws IOException, InterruptedException {
52
55
53
56
@ Override
54
57
public String commandName () {
55
- return "docker-compose" ;
58
+ File file = new File (defaultDockerComposePath ());
59
+ return file .getName ().equals ("docker-compose" ) ? "docker-compose" : "docker" ;
56
60
}
57
61
58
62
@ Override
59
63
public Process execute (String ... commands ) throws IOException {
60
64
List <String > args = new ArrayList <>();
61
- args .add (defaultDockerComposePath ());
65
+ String dockerComposePath = defaultDockerComposePath ();
66
+ args .add (dockerComposePath );
67
+ if (commandName ().equals ("docker" )) {
68
+ args .add ("compose" );
69
+ }
62
70
args .addAll (Arrays .asList (commands ));
63
71
log .debug ("execute:{}" , args );
64
72
return new ProcessBuilder (args ).redirectErrorStream (true ).start ();
@@ -98,7 +106,8 @@ public ProjectName projectName() {
98
106
99
107
@ Override
100
108
public final String commandName () {
101
- return "docker-compose" ;
109
+ File file = new File (defaultDockerComposePath ());
110
+ return file .getName ().equals ("docker-compose" ) ? "docker-compose" : "docker" ;
102
111
}
103
112
104
113
protected String dockerComposePath () {
@@ -110,7 +119,11 @@ public Process execute(String... commands) throws IOException {
110
119
DockerForMacHostsIssue .issueWarning ();
111
120
112
121
List <String > args = new ArrayList <>();
113
- args .add (dockerComposePath ());
122
+ String dockerComposePath = dockerComposePath ();
123
+ args .add (dockerComposePath );
124
+ if (commandName ().equals ("docker" )) {
125
+ args .add ("compose" );
126
+ }
114
127
// if a single option is provided that starts with - skips the file commands.
115
128
if (commands .length > 1 || commands [0 ].charAt (0 ) != '-' ) {
116
129
args .addAll (projectName ().constructComposeFileCommand ());
0 commit comments