Set correct env variables for `docker exec` commands
| ... | ... |
@@ -186,3 +186,30 @@ func TestExecAfterDaemonRestart(t *testing.T) {
|
| 186 | 186 |
|
| 187 | 187 |
logDone("exec - exec running container after daemon restart")
|
| 188 | 188 |
} |
| 189 |
+ |
|
| 190 |
+// Regresssion test for #9155, #9044 |
|
| 191 |
+func TestExecEnv(t *testing.T) {
|
|
| 192 |
+ defer deleteAllContainers() |
|
| 193 |
+ |
|
| 194 |
+ runCmd := exec.Command(dockerBinary, "run", |
|
| 195 |
+ "-e", "LALA=value1", |
|
| 196 |
+ "-e", "LALA=value2", |
|
| 197 |
+ "-d", "--name", "testing", "busybox", "top") |
|
| 198 |
+ if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
|
|
| 199 |
+ t.Fatal(out, err) |
|
| 200 |
+ } |
|
| 201 |
+ |
|
| 202 |
+ execCmd := exec.Command(dockerBinary, "exec", "testing", "env") |
|
| 203 |
+ out, _, err := runCommandWithOutput(execCmd) |
|
| 204 |
+ if err != nil {
|
|
| 205 |
+ t.Fatal(out, err) |
|
| 206 |
+ } |
|
| 207 |
+ |
|
| 208 |
+ if strings.Contains(out, "LALA=value1") || |
|
| 209 |
+ !strings.Contains(out, "LALA=value2") || |
|
| 210 |
+ !strings.Contains(out, "HOME=/root") {
|
|
| 211 |
+ t.Errorf("exec env(%q), expect %q, %q", out, "LALA=value2", "HOME=/root")
|
|
| 212 |
+ } |
|
| 213 |
+ |
|
| 214 |
+ logDone("exec - exec inherits correct env")
|
|
| 215 |
+} |