From b3ffc1f8358a9aa89448b37ea630c5783f0672d8 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Sat, 22 Feb 2014 20:01:45 -0700 Subject: [PATCH] Extract our default PATH value to a constant for great reuse Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) --- buildfile.go | 2 +- container.go | 4 +++- links/links.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/buildfile.go b/buildfile.go index b30a220ddc..6fae6a24a5 100644 --- a/buildfile.go +++ b/buildfile.go @@ -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 { diff --git a/container.go b/container.go index ca53bb57c7..3a277fb1f9 100644 --- a/container.go +++ b/container.go @@ -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, } diff --git a/links/links.go b/links/links.go index 68ac98ee07..7665a06a11 100644 --- a/links/links.go +++ b/links/links.go @@ -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 }