Setting dockerBinary to the full path of the Docker binary is a good
idea and this is now done in the test code.
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -1,7 +1,9 @@ |
| 1 | 1 |
package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "fmt" |
|
| 4 | 5 |
"os" |
| 6 |
+ "os/exec" |
|
| 5 | 7 |
) |
| 6 | 8 |
|
| 7 | 9 |
// the docker binary to use |
| ... | ... |
@@ -18,6 +20,15 @@ var workingDirectory string |
| 18 | 18 |
func init() {
|
| 19 | 19 |
if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
|
| 20 | 20 |
dockerBinary = dockerBin |
| 21 |
+ } else {
|
|
| 22 |
+ whichCmd := exec.Command("which", "docker")
|
|
| 23 |
+ out, _, err := runCommandWithOutput(whichCmd) |
|
| 24 |
+ if err == nil {
|
|
| 25 |
+ dockerBinary = stripTrailingCharacters(out) |
|
| 26 |
+ } else {
|
|
| 27 |
+ fmt.Printf("ERROR: couldn't resolve full path to the Docker binary")
|
|
| 28 |
+ os.Exit(1) |
|
| 29 |
+ } |
|
| 21 | 30 |
} |
| 22 | 31 |
if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
|
| 23 | 32 |
registryImageName = registryImage |