@@ -17,6 +17,7 @@ limitations under the License.
17
17
package system
18
18
19
19
import (
20
+ "bytes"
20
21
"encoding/json"
21
22
"os/exec"
22
23
"regexp"
@@ -63,16 +64,27 @@ func (d *DockerValidator) Validate(spec SysSpec) ([]error, []error) {
63
64
64
65
// Run 'docker info' with a JSON output and unmarshal it into a dockerInfo object
65
66
info := dockerInfo {}
66
- out , err := exec .Command ("docker" , "info" , "--format" , "{{json .}}" ).CombinedOutput ()
67
+ cmd := exec .Command ("docker" , "info" , "--format" , "{{json .}}" )
68
+
69
+ // Stderr can contain warnings despite docker info success.
70
+ var outb , errb bytes.Buffer
71
+ cmd .Stdout = & outb
72
+ cmd .Stderr = & errb
73
+ err := cmd .Run ()
67
74
if err != nil {
68
- return nil , []error {errors .Errorf (`failed executing "docker info --format '{{json .}}'"\noutput: %s\nerror: %v` , string ( out ), err )}
75
+ return nil , []error {errors .Errorf (`failed executing "docker info --format '{{json .}}'"\noutput: %s\nstderr: %s\ nerror: %v` , outb . String (), errb . String ( ), err )}
69
76
}
70
- if err := d .unmarshalDockerInfo (out , & info ); err != nil {
77
+ if err := d .unmarshalDockerInfo (outb . Bytes () , & info ); err != nil {
71
78
return nil , []error {err }
72
79
}
73
80
74
81
// validate the resulted docker info object against the spec
75
- return d .validateDockerInfo (spec .RuntimeSpec .DockerSpec , info )
82
+ warnings , errs := d .validateDockerInfo (spec .RuntimeSpec .DockerSpec , info )
83
+
84
+ if len (errb .String ()) > 0 {
85
+ warnings = append (warnings , errors .Errorf (`the command "docker info --format '{{json.}}'" succeeded with potential warnings\noutput: %s` , errb .String ()))
86
+ }
87
+ return warnings , errs
76
88
}
77
89
78
90
func (d * DockerValidator ) unmarshalDockerInfo (b []byte , info * dockerInfo ) error {
0 commit comments