Ignore TMPDIR when run container

This commit is contained in:
Donny Xia
2020-08-04 10:48:59 -07:00
parent c9e8631399
commit 60422c8090
2 changed files with 30 additions and 1 deletions

View File

@@ -195,7 +195,7 @@ func (c *Filter) getCommand() (string, []string) {
// export the local environment vars to the container
for _, pair := range os.Environ() {
items := strings.Split(pair, "=")
if items[0] == "" || items[1] == "" {
if items[0] == "" || items[1] == "" || shouldEnvIgnored(items[0]) {
continue
}
args = append(args, "-e", items[0])
@@ -203,3 +203,15 @@ func (c *Filter) getCommand() (string, []string) {
a := append(args, c.Image)
return "docker", a
}
// shouldEnvIgnored returns true if the environment variable key should be ignored
// by the container runtime.
func shouldEnvIgnored(envKey string) bool {
ignoreEnvKey := []string{"TMPDIR"}
for _, k := range ignoreEnvKey {
if k == envKey {
return true
}
}
return false
}