mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	A fix for = in env values in linked containers
Closes: #12763 Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
		
							parent
							
								
									300a12f9aa
								
							
						
					
					
						commit
						bc149be69c
					
				
					 2 changed files with 23 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -310,3 +310,24 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *check.C) {
 | 
			
		|||
		c.Fatalf("For 'onetwo' alias expected IP: %s, got: %s", realIP, ip)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *DockerSuite) TestLinksEnvs(c *check.C) {
 | 
			
		||||
	runCmd := exec.Command(dockerBinary, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top")
 | 
			
		||||
	out, _, _, err := runCommandWithStdoutStderr(runCmd)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		c.Fatalf("Run of first failed: %s\n%s", out, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	runCmd = exec.Command(dockerBinary, "run", "--name=second", "--link=first:first", "busybox", "env")
 | 
			
		||||
 | 
			
		||||
	out, stde, rc, err := runCommandWithStdoutStderr(runCmd)
 | 
			
		||||
	if err != nil || rc != 0 {
 | 
			
		||||
		c.Fatalf("run of 2nd failed: rc: %d, out: %s\n err: %s", rc, out, stde)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !strings.Contains(out, "FIRST_ENV_e1=\n") ||
 | 
			
		||||
		!strings.Contains(out, "FIRST_ENV_e2=v2") ||
 | 
			
		||||
		!strings.Contains(out, "FIRST_ENV_e3=v3=v3") {
 | 
			
		||||
		c.Fatalf("Incorrect output: %s", out)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,8 +107,8 @@ func (l *Link) ToEnv() []string {
 | 
			
		|||
 | 
			
		||||
	if l.ChildEnvironment != nil {
 | 
			
		||||
		for _, v := range l.ChildEnvironment {
 | 
			
		||||
			parts := strings.Split(v, "=")
 | 
			
		||||
			if len(parts) != 2 {
 | 
			
		||||
			parts := strings.SplitN(v, "=", 2)
 | 
			
		||||
			if len(parts) < 2 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			// Ignore a few variables that are added during docker build (and not really relevant to linked containers)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue