Merge pull request #4290 from tianon/extract-path

Extract our default PATH value to a constant for great reuse
This commit is contained in:
Victor Vieux 2014-02-24 14:06:27 -08:00
commit 5f15faf500
3 changed files with 5 additions and 3 deletions

View file

@ -110,7 +110,7 @@ func (b *buildFile) CmdFrom(name string) error {
b.config = image.Config
}
if b.config.Env == nil || len(b.config.Env) == 0 {
b.config.Env = append(b.config.Env, "HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
b.config.Env = append(b.config.Env, "HOME=/", "PATH="+defaultPathEnv)
}
// Process ONBUILD triggers if they exist
if nTriggers := len(b.config.OnBuild); nTriggers != 0 {

View file

@ -23,6 +23,8 @@ import (
"time"
)
const defaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
var (
ErrNotATTY = errors.New("The PTY is not a file")
ErrNoTTY = errors.New("No PTY found")
@ -447,7 +449,7 @@ func (container *Container) Start() (err error) {
// Setup environment
env := []string{
"HOME=/",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PATH=" + defaultPathEnv,
"HOSTNAME=" + container.Config.Hostname,
}

View file

@ -72,7 +72,7 @@ func (l *Link) ToEnv() []string {
if len(parts) != 2 {
continue
}
// Ignore a few variables that are added during docker build
// Ignore a few variables that are added during docker build (and not really relevant to linked containers)
if parts[0] == "HOME" || parts[0] == "PATH" {
continue
}