зеркало из https://github.com/microsoft/docker.git
Add support for autodetected HOME from USER (if HOME is unset)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Родитель
f4db3985d9
Коммит
57b9467f45
|
@ -120,7 +120,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="+daemon.DefaultPathEnv)
|
||||
b.config.Env = append(b.config.Env, "PATH="+daemon.DefaultPathEnv)
|
||||
}
|
||||
// Process ONBUILD triggers if they exist
|
||||
if nTriggers := len(b.config.OnBuild); nTriggers != 0 {
|
||||
|
|
|
@ -1043,9 +1043,12 @@ func (container *Container) setupLinkedContainers() ([]string, error) {
|
|||
func (container *Container) createDaemonEnvironment(linkedEnv []string) []string {
|
||||
// Setup environment
|
||||
env := []string{
|
||||
"HOME=/",
|
||||
"PATH=" + DefaultPathEnv,
|
||||
"HOSTNAME=" + container.Config.Hostname,
|
||||
// Note: we don't set HOME here because it'll get autoset intelligently
|
||||
// based on the value of USER inside dockerinit, but only if it isn't
|
||||
// set already (ie, that can be overridden by setting HOME via -e or ENV
|
||||
// in a Dockerfile).
|
||||
}
|
||||
if container.Config.Tty {
|
||||
env = append(env, "TERM=xterm")
|
||||
|
|
|
@ -700,7 +700,7 @@ func TestBuildRelativeWorkdir(t *testing.T) {
|
|||
|
||||
func TestBuildEnv(t *testing.T) {
|
||||
name := "testbuildenv"
|
||||
expected := "[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]"
|
||||
expected := "[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]"
|
||||
defer deleteImages(name)
|
||||
_, err := buildImage(name,
|
||||
`FROM busybox
|
||||
|
|
|
@ -676,13 +676,13 @@ func TestEnvironment(t *testing.T) {
|
|||
|
||||
goodEnv := []string{
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"HOME=/",
|
||||
"HOSTNAME=testing",
|
||||
"FALSE=true",
|
||||
"TRUE=false",
|
||||
"TRICKY=tri",
|
||||
"cky",
|
||||
"",
|
||||
"HOME=/root",
|
||||
}
|
||||
sort.Strings(goodEnv)
|
||||
if len(goodEnv) != len(actualEnv) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче