@@ -344,7 +344,7 @@ func LoadEnvFiles(hostCwd string, optionVerbose bool) error {
344
344
return nil
345
345
}
346
346
347
- func dockerComposeRunAdHocService (service types.ServiceConfig , runOptions api.RunOptions ) error {
347
+ func dockerComposeRunAdHocService (service types.ServiceConfig , runOptions api.RunOptions ) ( error , int ) {
348
348
if service .Environment == nil {
349
349
service .Environment = map [string ]* string {}
350
350
}
@@ -357,7 +357,7 @@ func dockerComposeRunAdHocService(service types.ServiceConfig, runOptions api.Ru
357
357
}, runOptions , []types.ServiceVolumeConfig {})
358
358
}
359
359
360
- func DockerRun (image string , runOptions api.RunOptions , volumes []types.ServiceVolumeConfig ) error {
360
+ func DockerRun (image string , runOptions api.RunOptions , volumes []types.ServiceVolumeConfig ) ( error , int ) {
361
361
// Couldn't get 'docker run' to work, so instead define a Docker Compose Service and run that.
362
362
// This coincidentally allows re-using the same code for both 'docker run' and 'docker-compose run'
363
363
// - ContainerCreate is simple, but the logic to attach to it is very complex, and not exposed by the Docker SDK.
@@ -504,10 +504,10 @@ func DockerComposeBuild(composeFilePaths []string, buildOptions api.BuildOptions
504
504
return backend .Build (ctx , project , buildOptions )
505
505
}
506
506
507
- func DockerComposeRun (project * types.Project , runOptions api.RunOptions , volumes []types.ServiceVolumeConfig ) error {
507
+ func DockerComposeRun (project * types.Project , runOptions api.RunOptions , volumes []types.ServiceVolumeConfig ) ( error , int ) {
508
508
err := os .Chdir (project .WorkingDir )
509
509
if err != nil {
510
- return err
510
+ return err , 1
511
511
}
512
512
ctx , _ := newSigContext ()
513
513
@@ -525,24 +525,24 @@ func DockerComposeRun(project *types.Project, runOptions api.RunOptions, volumes
525
525
526
526
backend , err := getBackend ()
527
527
if err != nil {
528
- return err
528
+ return err , 1
529
529
}
530
530
531
531
err = dockerComposeUpNetworkOnly (backend , ctx , project )
532
532
if err != nil {
533
- return err
533
+ return err , 1
534
534
}
535
535
536
536
project .Services = []types.ServiceConfig {service }
537
537
538
538
exitCode , err := backend .RunOneOffContainer (ctx , project , runOptions )
539
539
if err != nil {
540
- return err
540
+ return err , exitCode
541
541
}
542
542
if exitCode != 0 {
543
- return fmt .Errorf ("docker-compose exited with code %d" , exitCode )
543
+ return fmt .Errorf ("%s exited with code %d" , serviceName , exitCode ), exitCode
544
544
}
545
- return nil
545
+ return nil , 0
546
546
}
547
547
548
548
func unique (s []string ) []string {
0 commit comments