{"record":{"id":"090ba97c9036fa2f","repo":"hashicorp/nomad","slug":"failed-to-build-mount-for-resolv-conf-v-090ba9","errorCode":null,"errorMessage":"failed to build mount for resolv.conf: %v","messagePattern":"failed to build mount for resolv\\.conf: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/exec/driver.go","lineNumber":498,"sourceCode":"\t}\n\n\td.logger.Info(\"starting task\", \"driver_cfg\", hclog.Fmt(\"%+v\", driverConfig))\n\thandle = drivers.NewTaskHandle(taskHandleVersion)\n\thandle.Config = cfg\n\n\tpluginLogFile := filepath.Join(cfg.TaskDir().Dir, \"executor.out\")\n\texecutorConfig := &executor.ExecutorConfig{\n\t\tLogFile:     pluginLogFile,\n\t\tLogLevel:    \"debug\",\n\t\tFSIsolation: true,\n\t\tCompute:     d.compute,\n\t}\n\n\tuser := cfg.User\n\tif cfg.DNS != nil {\n\t\tdnsMount, err := resolvconf.GenerateDNSMount(cfg.TaskDir().Dir, cfg.DNS)\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to build mount for resolv.conf: %v\", err)\n\t\t}\n\t\tcfg.Mounts = append(cfg.Mounts, dnsMount)\n\t}\n\n\tcaps, err := capabilities.Calculate(\n\t\tcapabilities.NomadDefaults(), d.config.AllowCaps, driverConfig.CapAdd, driverConfig.CapDrop,\n\t)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\td.logger.Debug(\"task capabilities\", \"capabilities\", caps)\n\n\texec, pluginClient, err := executor.CreateExecutor(\n\t\td.logger.With(\"task_name\", handle.Config.Name, \"alloc_id\", handle.Config.AllocID),\n\t\td.nomadConfig, executorConfig)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to create executor: %v\", err)\n\t}","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/exec/driver.go#L480-L516","documentation":"When the task carries a DNS configuration, StartTask asks resolvconf.GenerateDNSMount to build a bind mount for /etc/resolv.conf in the task directory. Failure here (usually inability to write the generated resolv.conf under the task dir) prevents launch.","triggerScenarios":"cfg.DNS is set and GenerateDNSMount fails writing the resolv.conf file into cfg.TaskDir().Dir, typically due to filesystem permissions, a read-only or full task dir, or path issues.","commonSituations":"Task directory permissions broken after restores; disk full on the client; chroot dir not writable by the nomad user; custom dns block in the job combined with restricted filesystems.","solutions":["Check the task directory exists, is writable by the nomad user, and has free space (df).","Fix permissions on the allocation/task dir (e.g., chown -R nomad:nomad).","If custom DNS is unnecessary, remove the 'dns' block from the task to skip the mount.","Check the wrapped error from GenerateDNSMount in client logs for the exact filesystem cause."],"exampleFix":"// before (job)\nresources { } \ntask \"app\" { dns { servers = [\"10.0.0.10\"] } } // fails: task dir read-only\n// after (on host)\nsudo chown -R nomad:nomad /var/lib/nomad/client\n# then resubmit the job unchanged","handlingStrategy":"validation","validationCode":"// check task dir is writable before starting tasks with custom DNS\ntest := filepath.Join(taskDir, \".write-test\")\nif err := os.WriteFile(test, []byte(\"ok\"), 0o644); err != nil {\n    return fmt.Errorf(\"task dir not writable for resolv.conf: %w\", err)\n}\nos.Remove(test)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure /var/lib/nomad is owned by the nomad user and not read-only.","Monitor client disk usage and inode availability.","Exclude Nomad data paths from hardened mounts (noexec is fine, ro is not)."],"tags":["nomad","exec-driver","dns","mount","filesystem"],"backgroundTag":"resolvconf-mount-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}