Skip to content

Commit

Permalink
Merge pull request moby#39389 from thaJeztah/fix_LCOW_healthchecks
Browse files Browse the repository at this point in the history
LCOW: fix using wrong shell for healthchecks
  • Loading branch information
yongtang committed Jul 6, 2019
2 parents 089757d + 3e6a13c commit 4abac69
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions daemon/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/container"
"github.com/docker/docker/daemon/exec"
Expand Down Expand Up @@ -65,7 +64,7 @@ type cmdProbe struct {
func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container) (*types.HealthcheckResult, error) {
cmdSlice := strslice.StrSlice(cntr.Config.Healthcheck.Test)[1:]
if p.shell {
cmdSlice = append(getShell(cntr.Config), cmdSlice...)
cmdSlice = append(getShell(cntr), cmdSlice...)
}
entrypoint, args := d.getEntrypointAndArgs(strslice.StrSlice{}, cmdSlice)
execConfig := exec.NewConfig()
Expand Down Expand Up @@ -376,12 +375,15 @@ func min(x, y int) int {
return y
}

func getShell(config *containertypes.Config) []string {
if len(config.Shell) != 0 {
return config.Shell
func getShell(cntr *container.Container) []string {
if len(cntr.Config.Shell) != 0 {
return cntr.Config.Shell
}
if runtime.GOOS != "windows" {
return []string{"/bin/sh", "-c"}
}
if cntr.OS != runtime.GOOS {
return []string{"/bin/sh", "-c"}
}
return []string{"cmd", "/S", "/C"}
}

0 comments on commit 4abac69

Please sign in to comment.