{"record":{"id":"933140b53c041ff3","repo":"hashicorp/nomad","slug":"failed-to-create-container-s-v","errorCode":null,"errorMessage":"failed to create container(%s): %v","messagePattern":"failed to create container\\((.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":207,"sourceCode":"\t\t\tNomadResources: &structs.AllocatedTaskResources{},\n\t\t}\n\t}\n\n\tl.command = command\n\n\t// A container groups processes under the same isolation enforcement\n\tcontainerCfg, err := l.newLibcontainerConfig(command)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to configure container(%s): %v\", l.id, err)\n\t}\n\n\tif err := l.cleanOldProcessesInCGroup(containerCfg.Cgroups.Path); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcontainer, err := libcontainer.Create(path.Join(command.TaskDir, \"../alloc/container\"), l.id, containerCfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create container(%s): %v\", l.id, err)\n\t}\n\tl.container = container\n\n\t// Look up the binary path and make it executable\n\ttaskPath, hostPath, err := lookupTaskBin(command)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := makeExecutable(hostPath); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcombined := append([]string{taskPath}, command.Args...)\n\tstdout, err := command.Stdout()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tstderr, err := command.Stderr()","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L189-L225","documentation":"Launch wraps failures from libcontainer.Create, which creates the container factory/directory at <alloc_dir>/container and instantiates the container with the prepared config. If the container cannot be created (bad path, factory error, id conflict), the launch aborts with this error including the container id and underlying cause.","triggerScenarios":"libcontainer.Create(path.Join(command.TaskDir, \"../alloc/container\"), l.id, containerCfg) errors: alloc/container directory cannot be created or written, factory initialization fails, or the container id is unusable.","commonSituations":"Alloc dir permissions broken or disk full so the container directory cannot be created; alloc directory removed mid-launch by GC; task dir not laid out under the expected alloc structure (custom/odd TaskDir); leftover stale container state in alloc/container.","solutions":["Check disk space and permissions on the alloc directory (and alloc/container) for the Nomad user","Verify the alloc dir wasn't garbage-collected or deleted while the task was starting; inspect client logs around the launch","Clear stale state under <alloc_dir>/container and retry the allocation","Confirm TaskDir layout matches Nomad expectations (TaskDir sits inside alloc_dir with sibling alloc/ directory)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"allocDir := filepath.Dir(cmd.TaskDir) // TaskDir must be <alloc>/<name>\nif err := os.MkdirAll(filepath.Join(allocDir, \"container\"), 0o755); err != nil {\n    return fmt.Errorf(\"alloc/container not creatable: %w\", err)\n}\nif stat, err := os.Stat(allocDir); err != nil || !isWritable(stat) {\n    return fmt.Errorf(\"alloc dir missing or not writable\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := executor.Launch(cmd); err != nil && strings.Contains(err.Error(), \"failed to create container\") {\n    log.Printf(\"container create failed: %v — check disk/alloc dir\", err)\n}","preventionTips":["Keep free disk space on the host volume backing alloc dirs","Prevent alloc GC from racing task launches (check client logs for GC timing)","Clean stale alloc/container state before retrying allocations"],"tags":["libcontainer","container-creation","filesystem","executor"],"backgroundTag":"container-create-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"}