1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #28438 from vdemeester/use-container-shell-instead-of-hardcoded

Use Container.Config.Shell instead of hardcoded…
This commit is contained in:
Victor Vieux 2016-11-18 18:54:36 -08:00 committed by GitHub
commit f6f67891be

View file

@ -12,6 +12,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types" "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/api/types/strslice"
"github.com/docker/docker/container" "github.com/docker/docker/container"
"github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/exec"
@ -63,11 +64,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, container *container.Cont
cmdSlice := strslice.StrSlice(container.Config.Healthcheck.Test)[1:] cmdSlice := strslice.StrSlice(container.Config.Healthcheck.Test)[1:]
if p.shell { if p.shell {
if runtime.GOOS != "windows" { cmdSlice = append(getShell(container.Config), cmdSlice...)
cmdSlice = append([]string{"/bin/sh", "-c"}, cmdSlice...)
} else {
cmdSlice = append([]string{"cmd", "/S", "/C"}, cmdSlice...)
}
} }
entrypoint, args := d.getEntrypointAndArgs(strslice.StrSlice{}, cmdSlice) entrypoint, args := d.getEntrypointAndArgs(strslice.StrSlice{}, cmdSlice)
execConfig := exec.NewConfig() execConfig := exec.NewConfig()
@ -332,3 +329,13 @@ func min(x, y int) int {
} }
return y return y
} }
func getShell(config *containertypes.Config) []string {
if len(config.Shell) != 0 {
return config.Shell
}
if runtime.GOOS != "windows" {
return []string{"/bin/sh", "-c"}
}
return []string{"cmd", "/S", "/C"}
}