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

Extract our default PATH value to a constant for great reuse

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Tianon Gravi 2014-02-22 20:01:45 -07:00
parent ed8466c44c
commit b3ffc1f835
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 b.config = image.Config
} }
if b.config.Env == nil || len(b.config.Env) == 0 { 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 // Process ONBUILD triggers if they exist
if nTriggers := len(b.config.OnBuild); nTriggers != 0 { if nTriggers := len(b.config.OnBuild); nTriggers != 0 {

View file

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

View file

@ -72,7 +72,7 @@ func (l *Link) ToEnv() []string {
if len(parts) != 2 { if len(parts) != 2 {
continue 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" { if parts[0] == "HOME" || parts[0] == "PATH" {
continue continue
} }